fix #133, dodge active window when switching desktop

pull/1/head
Johan Smith Agudelo Rodriguez 8 years ago
parent 8ac85c53a6
commit b8cbf694f7

@ -112,7 +112,8 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged
, this, &VisibilityManagerPrivate::dodgeActive); , this, &VisibilityManagerPrivate::dodgeActive);
connections[2] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged connections[2] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged
, this, [&](int) { , this, [&](int desktop) {
qDebug() << "desktop" << desktop;
dodgeActive(wm->activeWindow()); dodgeActive(wm->activeWindow());
}); });
dodgeActive(wm->activeWindow()); dodgeActive(wm->activeWindow());

@ -22,6 +22,7 @@
#include "../liblattedock/extras.h" #include "../liblattedock/extras.h"
#include <QDebug> #include <QDebug>
#include <QTimer>
#include <QtX11Extras/QX11Info> #include <QtX11Extras/QX11Info>
#include <KWindowSystem> #include <KWindowSystem>
@ -34,6 +35,9 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
: AbstractWindowInterface(view, parent) : AbstractWindowInterface(view, parent)
{ {
Q_ASSERT(view != nullptr); Q_ASSERT(view != nullptr);
m_currentDesktop = KWindowSystem::currentDesktop();
connections << connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged connections << connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
, this, &AbstractWindowInterface::activeWindowChanged); , this, &AbstractWindowInterface::activeWindowChanged);
connections << connect(KWindowSystem::self() connections << connect(KWindowSystem::self()
@ -56,7 +60,12 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
} }
}); });
connections << connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged 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 // fill windows list
foreach (const auto &wid, KWindowSystem::self()->windows()) { foreach (const auto &wid, KWindowSystem::self()->windows()) {
@ -156,7 +165,7 @@ WindowInfoWrap XWindowInterface::requestInfoActive() const
bool XWindowInterface::isOnCurrentDesktop(WId wid) const bool XWindowInterface::isOnCurrentDesktop(WId wid) const
{ {
KWindowInfo winfo(wid, NET::WMDesktop); KWindowInfo winfo(wid, NET::WMDesktop);
return winfo.valid() && winfo.isOnCurrentDesktop(); return winfo.valid() && winfo.desktop() == m_currentDesktop;
} }
WindowInfoWrap XWindowInterface::requestInfo(WId wid) const WindowInfoWrap XWindowInterface::requestInfo(WId wid) const

@ -54,6 +54,7 @@ private:
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2); void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
WId m_desktopId; WId m_desktopId;
int m_currentDesktop;
QList<QMetaObject::Connection> connections; QList<QMetaObject::Connection> connections;
}; };

Loading…
Cancel
Save