From b8cbf694f7b7e3fde55df0b292b27373b0248ac8 Mon Sep 17 00:00:00 2001 From: Johan Smith Agudelo Rodriguez Date: Sat, 11 Feb 2017 02:54:03 -0500 Subject: [PATCH] fix #133, dodge active window when switching desktop --- app/visibilitymanager.cpp | 3 ++- app/xwindowinterface.cpp | 13 +++++++++++-- app/xwindowinterface.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/visibilitymanager.cpp b/app/visibilitymanager.cpp index a53d8f82e..8d972da52 100644 --- a/app/visibilitymanager.cpp +++ b/app/visibilitymanager.cpp @@ -112,7 +112,8 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode) connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged , this, &VisibilityManagerPrivate::dodgeActive); connections[2] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged - , this, [&](int) { + , this, [&](int desktop) { + qDebug() << "desktop" << desktop; dodgeActive(wm->activeWindow()); }); dodgeActive(wm->activeWindow()); diff --git a/app/xwindowinterface.cpp b/app/xwindowinterface.cpp index bb7e691c0..3cb441bc1 100644 --- a/app/xwindowinterface.cpp +++ b/app/xwindowinterface.cpp @@ -22,6 +22,7 @@ #include "../liblattedock/extras.h" #include +#include #include #include @@ -34,6 +35,9 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent) : AbstractWindowInterface(view, parent) { Q_ASSERT(view != nullptr); + + m_currentDesktop = KWindowSystem::currentDesktop(); + connections << connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged , this, &AbstractWindowInterface::activeWindowChanged); connections << connect(KWindowSystem::self() @@ -56,7 +60,12 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent) } }); connections << connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged - , this, &AbstractWindowInterface::currentDesktopChanged); + , this, [&](int desktop) { + m_currentDesktop = desktop; + QTimer::singleShot(200, this, [&]() { + emit currentDesktopChanged(m_currentDesktop); + }); + }); // fill windows list foreach (const auto &wid, KWindowSystem::self()->windows()) { @@ -156,7 +165,7 @@ WindowInfoWrap XWindowInterface::requestInfoActive() const bool XWindowInterface::isOnCurrentDesktop(WId wid) const { KWindowInfo winfo(wid, NET::WMDesktop); - return winfo.valid() && winfo.isOnCurrentDesktop(); + return winfo.valid() && winfo.desktop() == m_currentDesktop; } WindowInfoWrap XWindowInterface::requestInfo(WId wid) const diff --git a/app/xwindowinterface.h b/app/xwindowinterface.h index 6ebded394..46f9adbb5 100644 --- a/app/xwindowinterface.h +++ b/app/xwindowinterface.h @@ -54,6 +54,7 @@ private: void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2); WId m_desktopId; + int m_currentDesktop; QList connections; };