From 945a034a8c55dbca3fb317d3909ed5763871e44e Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 22 Dec 2019 13:36:51 +0200 Subject: [PATCH] remove deprecated SignalMapper at waylandinterface --- app/wm/waylandinterface.cpp | 131 ++++++++++++++++++++++-------------- app/wm/waylandinterface.h | 10 ++- 2 files changed, 89 insertions(+), 52 deletions(-) diff --git a/app/wm/waylandinterface.cpp b/app/wm/waylandinterface.cpp index 81a149f54..4993a8cfa 100644 --- a/app/wm/waylandinterface.cpp +++ b/app/wm/waylandinterface.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -227,8 +226,8 @@ void WaylandInterface::registerIgnoredWindow(WindowId wid) KWayland::Client::PlasmaWindow *w = windowFor(wid); - if (mapper && w) { - mapper->removeMappings(w); + if (w) { + untrackWindow(w); } emit windowChanged(wid); @@ -660,66 +659,100 @@ bool WaylandInterface::isValidWindow(const KWayland::Client::PlasmaWindow *w) co return w->isValid() && !isPlasmaDesktop(w) && !m_plasmaPanels.contains(w->internalId()) && !m_ignoredWindows.contains(w->internalId()); } -void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w) +void WaylandInterface::updateWindow() { - if (!isValidWindow(w)) return; + PlasmaWindow *pW = qobject_cast(QObject::sender()); - if (!mapper) mapper = new QSignalMapper(this); + if (pW && !m_ignoredWindows.contains(pW->internalId() && !isPlasmaDesktop(pW) )) { + if (pW->appId() == QLatin1String("org.kde.plasmashell")) { + if (isPlasmaDesktop(pW)) { + return; + } else if (isPlasmaPanel(pW)) { + registerIgnoredWindow(pW->internalId()); + } + } - mapper->setMapping(w, w); + considerWindowChanged(pW->internalId()); + } +} - connect(w, &PlasmaWindow::unmapped, this, [ &, win = w]() noexcept { - mapper->removeMappings(win); - emit windowRemoved(win->internalId()); - }); +void WaylandInterface::windowUnmapped() +{ + PlasmaWindow *pW = qobject_cast(QObject::sender()); - connect(w, SIGNAL(activeChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(titleChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(fullscreenChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(geometryChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(maximizedChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(minimizedChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(shadedChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(skipTaskbarChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(onAllDesktopsChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(virtualDesktopChanged()), mapper, SLOT(map()) ); - connect(w, SIGNAL(parentWindowChanged()), mapper, SLOT(map()) ); + if (pW) { + untrackWindow(pW); + emit windowRemoved(pW->internalId()); + } +} + +void WaylandInterface::trackWindow(KWayland::Client::PlasmaWindow *w) +{ + if (!w) { + return; + } + + connect(w, &PlasmaWindow::activeChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::titleChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::fullscreenChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::geometryChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::maximizedChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::minimizedChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::shadedChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::skipTaskbarChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::onAllDesktopsChanged, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::parentWindowChanged, this, &WaylandInterface::updateWindow); #if KF5_VERSION_MINOR >= 52 - connect(w, &KWayland::Client::PlasmaWindow::plasmaVirtualDesktopEntered, this, - [w, this] { - mapper->map(w); - }); + connect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow); + connect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow); +#else + connect(w, &PlasmaWindow::virtualDesktopChanged, this, &WaylandInterface::updateWindow); +#endif - connect(w, &KWayland::Client::PlasmaWindow::plasmaVirtualDesktopLeft, this, - [w, this] { - mapper->map(w); - }); + connect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped); +} + +void WaylandInterface::untrackWindow(KWayland::Client::PlasmaWindow *w) +{ + if (!w) { + return; + } + + disconnect(w, &PlasmaWindow::activeChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::titleChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::fullscreenChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::geometryChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::maximizedChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::minimizedChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::shadedChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::skipTaskbarChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::onAllDesktopsChanged, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::parentWindowChanged, this, &WaylandInterface::updateWindow); + +#if KF5_VERSION_MINOR >= 52 + disconnect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow); + disconnect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow); +#else + disconnect(w, &PlasmaWindow::virtualDesktopChanged, this, &WaylandInterface::updateWindow); #endif - connect(mapper, static_cast(&QSignalMapper::mapped) - , this, [&](QObject * w) noexcept { - //qDebug() << "window changed:" << qobject_cast(w)->appId(); - PlasmaWindow *pW = qobject_cast(w); - - if (pW && !m_ignoredWindows.contains(pW->internalId() && !isPlasmaDesktop(pW) )) { - if (pW->appId() == QLatin1String("org.kde.plasmashell")) { - if (isPlasmaDesktop(pW)) { - return; - } else if (isPlasmaPanel(pW)) { - registerIgnoredWindow(pW->internalId()); - } - } + disconnect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped); +} - considerWindowChanged(pW->internalId()); - } - }); - if (isPlasmaPanel(w)) { - registerPlasmaPanel(w->internalId()); +void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w) +{ + if (!isValidWindow(w)) { + return; } - emit windowAdded(w->internalId()); + if ((w->appId() == QLatin1String("org.kde.plasmashell")) && isPlasmaPanel(w)) { + registerPlasmaPanel(w->internalId()); + } else { + trackWindow(w); + emit windowAdded(w->internalId()); + } if (w->appId() == "latte-dock") { emit latteWindowAdded(); diff --git a/app/wm/waylandinterface.h b/app/wm/waylandinterface.h index c755ec84f..5d5796b93 100644 --- a/app/wm/waylandinterface.h +++ b/app/wm/waylandinterface.h @@ -29,7 +29,6 @@ // Qt #include #include -#include // KDE #include @@ -106,12 +105,19 @@ public: void initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement); #endif +private slots: + void updateWindow(); + void windowUnmapped(); + private: void init(); bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const; bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const; bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) const; void windowCreatedProxy(KWayland::Client::PlasmaWindow *w); + void trackWindow(KWayland::Client::PlasmaWindow *w); + void untrackWindow(KWayland::Client::PlasmaWindow *w); + KWayland::Client::PlasmaWindow *windowFor(WindowId wid) const; KWayland::Client::PlasmaShell *waylandCoronaInterface() const; @@ -122,8 +128,6 @@ private: #endif private: - QSignalMapper *mapper{nullptr}; - friend class Private::GhostWindow; mutable QMap m_ghostWindows;