remove deprecated SignalMapper at waylandinterface

pull/10/head
Michail Vourlakos 5 years ago
parent d31d7afb9d
commit 945a034a8c

@ -30,7 +30,6 @@
#include <QDebug> #include <QDebug>
#include <QTimer> #include <QTimer>
#include <QApplication> #include <QApplication>
#include <QSignalMapper>
#include <QtX11Extras/QX11Info> #include <QtX11Extras/QX11Info>
#include <QRasterWindow> #include <QRasterWindow>
@ -227,8 +226,8 @@ void WaylandInterface::registerIgnoredWindow(WindowId wid)
KWayland::Client::PlasmaWindow *w = windowFor(wid); KWayland::Client::PlasmaWindow *w = windowFor(wid);
if (mapper && w) { if (w) {
mapper->removeMappings(w); untrackWindow(w);
} }
emit windowChanged(wid); 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()); 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<PlasmaWindow*>(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 { void WaylandInterface::windowUnmapped()
mapper->removeMappings(win); {
emit windowRemoved(win->internalId()); PlasmaWindow *pW = qobject_cast<PlasmaWindow*>(QObject::sender());
});
connect(w, SIGNAL(activeChanged()), mapper, SLOT(map()) ); if (pW) {
connect(w, SIGNAL(titleChanged()), mapper, SLOT(map()) ); untrackWindow(pW);
connect(w, SIGNAL(fullscreenChanged()), mapper, SLOT(map()) ); emit windowRemoved(pW->internalId());
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()) ); void WaylandInterface::trackWindow(KWayland::Client::PlasmaWindow *w)
connect(w, SIGNAL(skipTaskbarChanged()), mapper, SLOT(map()) ); {
connect(w, SIGNAL(onAllDesktopsChanged()), mapper, SLOT(map()) ); if (!w) {
connect(w, SIGNAL(virtualDesktopChanged()), mapper, SLOT(map()) ); return;
connect(w, SIGNAL(parentWindowChanged()), mapper, SLOT(map()) ); }
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 #if KF5_VERSION_MINOR >= 52
connect(w, &KWayland::Client::PlasmaWindow::plasmaVirtualDesktopEntered, this, connect(w, &PlasmaWindow::plasmaVirtualDesktopEntered, this, &WaylandInterface::updateWindow);
[w, this] { connect(w, &PlasmaWindow::plasmaVirtualDesktopLeft, this, &WaylandInterface::updateWindow);
mapper->map(w); #else
}); connect(w, &PlasmaWindow::virtualDesktopChanged, this, &WaylandInterface::updateWindow);
#endif
connect(w, &KWayland::Client::PlasmaWindow::plasmaVirtualDesktopLeft, this, connect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped);
[w, this] { }
mapper->map(w);
}); 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 #endif
connect(mapper, static_cast<void (QSignalMapper::*)(QObject *)>(&QSignalMapper::mapped) disconnect(w, &PlasmaWindow::unmapped, this, &WaylandInterface::windowUnmapped);
, this, [&](QObject * w) noexcept { }
//qDebug() << "window changed:" << qobject_cast<PlasmaWindow *>(w)->appId();
PlasmaWindow *pW = qobject_cast<PlasmaWindow*>(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());
}
}
considerWindowChanged(pW->internalId());
}
});
if (isPlasmaPanel(w)) { void WaylandInterface::windowCreatedProxy(KWayland::Client::PlasmaWindow *w)
registerPlasmaPanel(w->internalId()); {
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") { if (w->appId() == "latte-dock") {
emit latteWindowAdded(); emit latteWindowAdded();

@ -29,7 +29,6 @@
// Qt // Qt
#include <QMap> #include <QMap>
#include <QObject> #include <QObject>
#include <QSignalMapper>
// KDE // KDE
#include <KWayland/Client/registry.h> #include <KWayland/Client/registry.h>
@ -106,12 +105,19 @@ public:
void initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement); void initVirtualDesktopManagement(KWayland::Client::PlasmaVirtualDesktopManagement *virtualDesktopManagement);
#endif #endif
private slots:
void updateWindow();
void windowUnmapped();
private: private:
void init(); void init();
bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const; bool isValidWindow(const KWayland::Client::PlasmaWindow *w) const;
bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const; bool isPlasmaDesktop(const KWayland::Client::PlasmaWindow *w) const;
bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) const; bool isPlasmaPanel(const KWayland::Client::PlasmaWindow *w) const;
void windowCreatedProxy(KWayland::Client::PlasmaWindow *w); 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::PlasmaWindow *windowFor(WindowId wid) const;
KWayland::Client::PlasmaShell *waylandCoronaInterface() const; KWayland::Client::PlasmaShell *waylandCoronaInterface() const;
@ -122,8 +128,6 @@ private:
#endif #endif
private: private:
QSignalMapper *mapper{nullptr};
friend class Private::GhostWindow; friend class Private::GhostWindow;
mutable QMap<WindowId, Private::GhostWindow *> m_ghostWindows; mutable QMap<WindowId, Private::GhostWindow *> m_ghostWindows;

Loading…
Cancel
Save