Skip to content

Commit

Permalink
Fix xwayland's decoration titleBar and parent setting
Browse files Browse the repository at this point in the history
  • Loading branch information
wineee committed Oct 25, 2024
1 parent e730d37 commit d2467a6
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions examples/tinywl/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,51 @@ void Helper::init()
connect(m_xwayland, &WXWayland::surfaceAdded, this, [this] (WXWaylandSurface *surface) {
surface->safeConnect(&qw_xwayland_surface::notify_associate, this, [this, surface] {
auto wrapper = new SurfaceWrapper(qmlEngine(), surface, SurfaceWrapper::Type::XWayland);
wrapper->setNoDecoration(false);
m_foreignToplevel->addSurface(surface);
m_workspace->addSurface(wrapper);

// Setup title and decoration
auto xwayland = qobject_cast<WXWaylandSurface *>(wrapper->shellSurface());
auto updateDecorationTitleBar = [this, wrapper, xwayland]() {
if (!xwayland->isBypassManager()) {
if (xwayland->decorationsType() != WXWaylandSurface::DecorationsNoTitle)
wrapper->setNoTitleBar(false);
if (xwayland->decorationsType() != WXWaylandSurface::DecorationsNoBorder)
wrapper->setNoDecoration(false);
}
};
connect(xwayland, &WXWaylandSurface::bypassManagerChanged, this, updateDecorationTitleBar);
connect(xwayland,
&WXWaylandSurface::decorationsTypeChanged,
this,
updateDecorationTitleBar);
updateDecorationTitleBar();

// Setup container
auto updateSurfaceWithParentContainer = [this, wrapper, surface] {
if (wrapper->parentSurface())
wrapper->parentSurface()->removeSubSurface(wrapper);
if (wrapper->container())
wrapper->container()->removeSurface(wrapper);
if (auto parent = surface->parentXWaylandSurface()) {
auto parentWrapper = m_surfaceContainer->getSurface(parent);
auto container = qobject_cast<Workspace *>(parentWrapper->container());
Q_ASSERT(container);
parentWrapper->addSubSurface(wrapper);
container->addSurface(wrapper, parentWrapper->workspaceId());
} else {
m_workspace->addSurface(wrapper);
}
};
surface->safeConnect(&WXWaylandSurface::parentXWaylandSurfaceChanged,
this,
updateSurfaceWithParentContainer);
updateSurfaceWithParentContainer();

Q_ASSERT(wrapper->parentItem());
connect(wrapper, &SurfaceWrapper::requestShowWindowMenu, m_windowMenu, [this, wrapper] (QPoint pos) {
QMetaObject::invokeMethod(m_windowMenu, "showWindowMenu", QVariant::fromValue(wrapper), QVariant::fromValue(pos));
});

m_foreignToplevel->addSurface(surface);
});
surface->safeConnect(&qw_xwayland_surface::notify_dissociate, this, [this, surface] {
m_foreignToplevel->removeSurface(surface);
Expand Down

0 comments on commit d2467a6

Please sign in to comment.