diff --git a/shell/desktopview.cpp b/shell/desktopview.cpp --- a/shell/desktopview.cpp +++ b/shell/desktopview.cpp @@ -134,7 +134,6 @@ setFlags(Qt::Window); KWindowSystem::setType(winId(), NET::Normal); KWindowSystem::clearState(winId(), NET::FullScreen); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Normal); m_shellSurface->setSkipTaskbar(false); @@ -144,7 +143,6 @@ setFlags(Qt::Window | Qt::FramelessWindowHint); KWindowSystem::setType(winId(), NET::Desktop); KWindowSystem::setState(winId(), NET::KeepBelow); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Desktop); m_shellSurface->setSkipTaskbar(true); @@ -154,7 +152,6 @@ KWindowSystem::setType(winId(), NET::Normal); KWindowSystem::clearState(winId(), NET::FullScreen); setFlags(Qt::FramelessWindowHint | flags()); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Normal); m_shellSurface->setSkipTaskbar(false); @@ -164,7 +161,6 @@ setFlags(Qt::Window); KWindowSystem::setType(winId(), NET::Normal); KWindowSystem::setState(winId(), NET::FullScreen); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Normal); m_shellSurface->setSkipTaskbar(false); @@ -200,6 +196,18 @@ if (graphicObject) { graphicObject->setProperty("focus", false); } + } else if (e->type() == QEvent::PlatformSurface) { + if (auto pe = dynamic_cast(e)) { + switch (pe->surfaceEventType()) { + case QPlatformSurfaceEvent::SurfaceCreated: + setupWaylandIntegration(); + break; + case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed: + delete m_shellSurface; + m_shellSurface = nullptr; + break; + } + } } return PlasmaQuick::ContainmentView::event(e); diff --git a/shell/panelconfigview.h b/shell/panelconfigview.h --- a/shell/panelconfigview.h +++ b/shell/panelconfigview.h @@ -64,6 +64,7 @@ void hideEvent(QHideEvent *ev); void focusOutEvent(QFocusEvent *ev); void moveEvent(QMoveEvent *ev); + bool event(QEvent *e); public Q_SLOTS: void showAddWidgetDialog(); diff --git a/shell/panelconfigview.cpp b/shell/panelconfigview.cpp --- a/shell/panelconfigview.cpp +++ b/shell/panelconfigview.cpp @@ -235,26 +235,42 @@ void PanelConfigView::moveEvent(QMoveEvent *ev) { - if (!m_shellSurface) { - ShellCorona *c = qobject_cast(m_containment->corona()); - - if (c) { - using namespace KWayland::Client; - PlasmaShell *interface = c->waylandPlasmaShellInterface(); - if (!interface) { - return; - } - Surface *s = Surface::fromWindow(this); - if (!s) { - return; + if (m_shellSurface) { + m_shellSurface->setPosition(ev->pos()); + } +} + +bool PanelConfigView::event(QEvent *e) +{ + if (e->type() == QEvent::PlatformSurface) { + if (auto pe = dynamic_cast(e)) { + switch (pe->surfaceEventType()) { + case QPlatformSurfaceEvent::SurfaceCreated: + if (m_shellSurface) { + break; + } + if (ShellCorona *c = qobject_cast(m_containment->corona())) { + using namespace KWayland::Client; + PlasmaShell *interface = c->waylandPlasmaShellInterface(); + if (!interface) { + break; + } + Surface *s = Surface::fromWindow(this); + if (!s) { + break; + } + m_shellSurface = interface->createSurface(s, this); + } + break; + case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed: + delete m_shellSurface; + m_shellSurface = nullptr; + break; } - m_shellSurface = interface->createSurface(s, this); } } - if (m_shellSurface) { - m_shellSurface->setPosition(ev->pos()); - } + return PlasmaQuick::ConfigView::event(e); } void PanelConfigView::setVisibilityMode(PanelView::VisibilityMode mode) diff --git a/shell/panelview.cpp b/shell/panelview.cpp --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -396,7 +396,6 @@ const QPoint pos = geometryByDistance(m_distance).topLeft(); setPosition(pos); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setPosition(pos); } @@ -651,7 +650,6 @@ //don't setGeometry() to meke really sure we aren't doing a resize loop const QPoint pos = geometryByDistance(m_distance).topLeft(); setPosition(pos); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setPosition(pos); } @@ -669,7 +667,6 @@ themeChanged(); KWindowSystem::setOnAllDesktops(winId(), true); KWindowSystem::setType(winId(), NET::Dock); - setupWaylandIntegration(); if (m_shellSurface) { m_shellSurface->setRole(KWayland::Client::PlasmaShellSurface::Role::Panel); m_shellSurface->setSkipTaskbar(true); @@ -801,6 +798,19 @@ } break; } + case QEvent::PlatformSurface: + if (auto pe = dynamic_cast(e)) { + switch (pe->surfaceEventType()) { + case QPlatformSurfaceEvent::SurfaceCreated: + setupWaylandIntegration(); + break; + case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed: + delete m_shellSurface; + m_shellSurface = nullptr; + break; + } + } + break; default: break; }