diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index 2ae367e..d091590 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -12,12 +12,15 @@ #include #include +#include + namespace LayerShellQt { QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() : QWaylandShellIntegrationTemplate(5) , m_xdgActivation(new QWaylandXdgActivationV1) { + qGuiApp->installEventFilter(this); } QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration() @@ -32,4 +35,29 @@ QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShel return new QWaylandLayerSurface(this, window); } +bool QWaylandLayerShellIntegration::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() == QEvent::PlatformSurface && static_cast(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) { + QWindow *window = qobject_cast(watched); + if (!window) { + return false; + } + auto child = static_cast(window->handle()); + auto maybeSetParent = [child]() { + auto transientParent = child->window()->transientParent(); + if (!transientParent) { + return; + } + if (auto layerParent = qobject_cast(static_cast(transientParent->handle())->shellSurface())) { + if (auto topevel = child->surfaceRole()) { + layerParent->set_parent_of(topevel); + } + } + }; + maybeSetParent(); + connect(window, &QWindow::transientParentChanged, child, maybeSetParent); + connect(child, &QtWaylandClient::QWaylandWindow::surfaceRoleCreated, this, maybeSetParent); + } + return false; +} } diff --git a/src/qwaylandlayershellintegration_p.h b/src/qwaylandlayershellintegration_p.h index 3e2306f..bd4f28a 100644 --- a/src/qwaylandlayershellintegration_p.h +++ b/src/qwaylandlayershellintegration_p.h @@ -32,6 +32,7 @@ public: QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override; private: + bool eventFilter(QObject *watched, QEvent *event) override; QScopedPointer m_xdgActivation; }; diff --git a/src/wlr-layer-shell-unstable-v1.xml b/src/wlr-layer-shell-unstable-v1.xml index ba4bb61..edc5327 100644 --- a/src/wlr-layer-shell-unstable-v1.xml +++ b/src/wlr-layer-shell-unstable-v1.xml @@ -403,5 +403,11 @@ + + + + + +