diff --git a/frame/layershell/dlayershellwindow.cpp b/frame/layershell/dlayershellwindow.cpp index 7261b1eff..ba6833eb7 100644 --- a/frame/layershell/dlayershellwindow.cpp +++ b/frame/layershell/dlayershellwindow.cpp @@ -6,6 +6,7 @@ #include "qwaylandlayershellintegration_p.h" #include +#include #include #include #include @@ -261,7 +262,8 @@ DLayerShellWindow::DLayerShellWindow(QWindow* window) s_map.insert(window, this); window->create(); if (dynamic_cast(window->handle())) { - ensureWaylandShellIntegration(); + window->installEventFilter(this); + installWaylandShellIntegration(); } #ifdef BUILD_WITH_X11 else if (dynamic_cast(window->handle())) { @@ -274,13 +276,23 @@ DLayerShellWindow::DLayerShellWindow(QWindow* window) } } -bool DLayerShellWindow::ensureWaylandShellIntegration() +bool DLayerShellWindow::eventFilter(QObject *watched, QEvent *event) { - auto *window = d->parentWindow; - if (!window->handle()) - window->create(); + if (watched == d->parentWindow && event->type() == QEvent::PlatformSurface) { + auto *surfaceEvent = static_cast(event); + if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated + && dynamic_cast(d->parentWindow->handle())) { + // Only bind the existing platform window; never create one from this event. + if (!installWaylandShellIntegration()) + qCWarning(layershellwindow) << "Failed to restore layer-shell integration for" << d->scope; + } + } + return QObject::eventFilter(watched, event); +} - auto *waylandWindow = dynamic_cast(window->handle()); +bool DLayerShellWindow::installWaylandShellIntegration() +{ + auto *waylandWindow = dynamic_cast(d->parentWindow->handle()); if (!waylandWindow) return false; diff --git a/frame/layershell/dlayershellwindow.h b/frame/layershell/dlayershellwindow.h index 5579558a7..12217adbd 100644 --- a/frame/layershell/dlayershellwindow.h +++ b/frame/layershell/dlayershellwindow.h @@ -148,8 +148,6 @@ class DS_SHARE DLayerShellWindow : public QObject void setCloseOnDismissed(bool close); bool closeOnDismissed() const; - bool ensureWaylandShellIntegration(); - /** Whether a system resize is pending or active on this layer surface. */ bool isResizing() const; @@ -178,6 +176,8 @@ class DS_SHARE DLayerShellWindow : public QObject friend class QWaylandLayerShellSurface; void setResizing(bool resizing); + bool eventFilter(QObject *watched, QEvent *event) override; + bool installWaylandShellIntegration(); DLayerShellWindow(QWindow* window); QScopedPointer d; }; diff --git a/panels/dock/dockhelper.cpp b/panels/dock/dockhelper.cpp index e3767bcb1..71e11be0d 100644 --- a/panels/dock/dockhelper.cpp +++ b/panels/dock/dockhelper.cpp @@ -309,8 +309,11 @@ void DockHelper::initAreas() if (m_areas.contains(screen)) return; m_areas.insert(screen, createArea(screen)); + updateAllDockWakeArea(); }); + connect(qApp, &QGuiApplication::primaryScreenChanged, this, &DockHelper::updateAllDockWakeArea); + connect(qApp, &QGuiApplication::screenRemoved, this, [this](QScreen *screen) { if (!m_areas.contains(screen)) return; diff --git a/panels/dock/dockpanel.cpp b/panels/dock/dockpanel.cpp index 3defb3fec..a409a456f 100644 --- a/panels/dock/dockpanel.cpp +++ b/panels/dock/dockpanel.cpp @@ -6,7 +6,6 @@ #include "constants.h" #include "dockadaptor.h" #include "docksettings.h" -#include "layershell/dlayershellwindow.h" #include "panel.h" #include "pluginfactory.h" #include "waylanddockhelper.h" @@ -512,8 +511,7 @@ void DockPanel::updateDockScreen() auto *waylandScreen = dynamic_cast(primary->handle()); if (!waylandScreen || !waylandScreen->output()) return; - if (DS_NAMESPACE::DLayerShellWindow::get(win)->ensureWaylandShellIntegration()) - win->show(); + win->show(); } bool DockPanel::showInPrimary() const diff --git a/panels/dock/waylanddockhelper.cpp b/panels/dock/waylanddockhelper.cpp index 8164ac94b..08cb86f52 100644 --- a/panels/dock/waylanddockhelper.cpp +++ b/panels/dock/waylanddockhelper.cpp @@ -147,6 +147,7 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel) connect(m_panel, &DockPanel::positionChanged, this, &WaylandDockHelper::updateRegionWatchPos); connect(m_panel, &DockPanel::dockSizeChanged, this, &WaylandDockHelper::updateRegionWatchPos); + connect(m_panel, &DockPanel::dockScreenChanged, this, &WaylandDockHelper::updateRegionWatchPos); connect(m_panel, &DockPanel::rootObjectChanged, this, &WaylandDockHelper::updateRegionWatchPos); auto ensureRegionWatch = [this]() {