mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-31 13:47:20 +03:00
fix #133, dodge active window when switching desktop
This commit is contained in:
parent
8ac85c53a6
commit
b8cbf694f7
@ -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());
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "../liblattedock/extras.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QtX11Extras/QX11Info>
|
||||
|
||||
#include <KWindowSystem>
|
||||
@ -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
|
||||
|
@ -54,6 +54,7 @@ private:
|
||||
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
|
||||
|
||||
WId m_desktopId;
|
||||
int m_currentDesktop;
|
||||
|
||||
QList<QMetaObject::Connection> connections;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user