diff --git a/app/mainwindow.h b/app/mainwindow.h --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -44,6 +44,7 @@ namespace KWayland { namespace Client { class PlasmaShell; + class PlasmaShellSurface; } } #endif @@ -203,7 +204,9 @@ #if HAVE_KWAYLAND void initWayland(); + void initWaylandSurface(); KWayland::Client::PlasmaShell *m_plasmaShell; + KWayland::Client::PlasmaShellSurface *m_plasmaShellSurface; #endif }; diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -95,6 +95,7 @@ m_isWayland = QGuiApplication::platformName().startsWith(QLatin1String("wayland")); #if HAVE_KWAYLAND m_plasmaShell = Q_NULLPTR; + m_plasmaShellSurface = Q_NULLPTR; initWayland(); #endif @@ -176,6 +177,21 @@ registry->setup(); connection->roundtrip(); } + +void MainWindow::initWaylandSurface() +{ + if (m_plasmaShellSurface) { + return; + } + if (!m_plasmaShell) { + return; + } + if (auto surface = KWayland::Client::Surface::fromWindow(windowHandle())) { + m_plasmaShellSurface = m_plasmaShell->createSurface(surface, this); + m_plasmaShellSurface->setPosition(pos()); + } +} + #endif bool MainWindow::queryClose() @@ -861,13 +877,7 @@ setGeometry(workArea.x() + workArea.width() * newPosition * (100 - newWidth) / 10000, workArea.y(), targetWidth, maxHeight); #if HAVE_KWAYLAND - if (m_plasmaShell) { - if (auto surface = KWayland::Client::Surface::fromWindow(windowHandle())) { - if (auto plasmaSurface = m_plasmaShell->createSurface(surface, this)) { - plasmaSurface->setPosition(pos()); - } - } - } + initWaylandSurface(); #endif maxHeight -= m_titleBar->height(); @@ -1303,6 +1313,10 @@ applyWindowProperties(); +#if HAVE_KWAYLAND + initWaylandSurface(); +#endif + emit windowOpened(); } @@ -1316,6 +1330,11 @@ { if (Settings::pollMouse()) toggleMousePoll(true); +#if HAVE_KWAYLAND + delete m_plasmaShellSurface; + m_plasmaShellSurface = Q_NULLPTR; +#endif + emit windowClosed(); }