mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-07 09:18:03 +03:00
fix #85,respect kwin vds navigation wrapping around
--respect and track KWin option for Virtual Desktops navigation wrapping around setting
This commit is contained in:
parent
53674a65e1
commit
58c7093be9
@ -14,6 +14,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QtDBus>
|
||||
|
||||
// KDE
|
||||
#include <KActivities/Controller>
|
||||
@ -24,8 +25,12 @@ namespace WindowSystem {
|
||||
#define MAXPLASMAPANELTHICKNESS 96
|
||||
#define MAXSIDEPANELTHICKNESS 512
|
||||
|
||||
#define KWINSERVICE "org.kde.KWin"
|
||||
#define KWINVIRTUALDESKTOPMANAGERNAMESPACE "org.kde.KWin.VirtualDesktopManager"
|
||||
|
||||
AbstractWindowInterface::AbstractWindowInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
: QObject(parent),
|
||||
m_kwinServiceWatcher(new QDBusServiceWatcher(this))
|
||||
{
|
||||
m_activities = new KActivities::Consumer(this);
|
||||
m_currentActivity = m_activities->currentActivity();
|
||||
@ -56,6 +61,22 @@ AbstractWindowInterface::AbstractWindowInterface(QObject *parent)
|
||||
emit currentActivityChanged();
|
||||
});
|
||||
|
||||
//! KWin Service tracking
|
||||
m_kwinServiceWatcher->setConnection(QDBusConnection::sessionBus());
|
||||
m_kwinServiceWatcher->setWatchedServices(QStringList({KWINSERVICE}));
|
||||
connect(m_kwinServiceWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this](const QString & serviceName) {
|
||||
if (serviceName == KWINSERVICE && !m_isKWinInterfaceAvailable) {
|
||||
initKWinInterface();
|
||||
}
|
||||
});
|
||||
|
||||
connect(m_kwinServiceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this](const QString & serviceName) {
|
||||
if (serviceName == KWINSERVICE && m_isKWinInterfaceAvailable) {
|
||||
m_isKWinInterfaceAvailable = false;
|
||||
}
|
||||
});
|
||||
|
||||
initKWinInterface();
|
||||
}
|
||||
|
||||
AbstractWindowInterface::~AbstractWindowInterface()
|
||||
@ -187,6 +208,42 @@ bool AbstractWindowInterface::inCurrentDesktopActivity(const WindowInfoWrap &win
|
||||
return (winfo.isValid() && winfo.isOnDesktop(currentDesktop()) && winfo.isOnActivity(currentActivity()));
|
||||
}
|
||||
|
||||
//! KWin Interface
|
||||
void AbstractWindowInterface::initKWinInterface()
|
||||
{
|
||||
QDBusInterface kwinIface(KWINSERVICE, "/VirtualDesktopManager", KWINVIRTUALDESKTOPMANAGERNAMESPACE, QDBusConnection::sessionBus());
|
||||
|
||||
if (kwinIface.isValid() && !m_isKWinInterfaceAvailable) {
|
||||
m_isKWinInterfaceAvailable = true;
|
||||
qDebug() << " KWIN SERVICE :: is available...";
|
||||
|
||||
QDBusReply<bool> navWrapAround = kwinIface.call("navigationWrappingAround");
|
||||
m_isVirtualDesktopNavigationWrappingAround = navWrapAround.value();
|
||||
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
bool signalconnected = bus.connect(KWINSERVICE,
|
||||
"/VirtualDesktopManager",
|
||||
KWINVIRTUALDESKTOPMANAGERNAMESPACE,
|
||||
"navigationWrappingAroundChanged",
|
||||
this,
|
||||
SLOT(onVirtualDesktopNavigationWrappingAroundChanged(bool)));
|
||||
|
||||
if (!signalconnected) {
|
||||
qDebug() << " KWIN SERVICE :: Virtual Desktop Manager :: navigationsWrappingSignal is not connected...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractWindowInterface::isVirtualDesktopNavigationWrappingAround() const
|
||||
{
|
||||
return m_isVirtualDesktopNavigationWrappingAround;
|
||||
}
|
||||
|
||||
void AbstractWindowInterface::onVirtualDesktopNavigationWrappingAroundChanged(bool navigationWrappingAround)
|
||||
{
|
||||
m_isVirtualDesktopNavigationWrappingAround = navigationWrappingAround;
|
||||
}
|
||||
|
||||
//! Register Latte Ignored Windows in order to NOT be tracked
|
||||
void AbstractWindowInterface::registerIgnoredWindow(WindowId wid)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
// Qt
|
||||
#include <QObject>
|
||||
#include <QWindow>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QRect>
|
||||
@ -174,13 +175,23 @@ protected:
|
||||
bool isPlasmaPanel(const QRect &wGeometry) const;
|
||||
bool isSidepanel(const QRect &wGeometry) const;
|
||||
|
||||
bool isVirtualDesktopNavigationWrappingAround() const;
|
||||
|
||||
private slots:
|
||||
void initKWinInterface();
|
||||
void windowRemovedSlot(WindowId wid);
|
||||
|
||||
void onVirtualDesktopNavigationWrappingAroundChanged(bool navigationWrappingAround);
|
||||
|
||||
private:
|
||||
bool m_isKWinInterfaceAvailable{false};
|
||||
bool m_isVirtualDesktopNavigationWrappingAround{true};
|
||||
|
||||
Latte::Corona *m_corona;
|
||||
Tracker::Schemes *m_schemesTracker;
|
||||
Tracker::Windows *m_windowsTracker;
|
||||
|
||||
QDBusServiceWatcher *m_kwinServiceWatcher{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -328,8 +328,12 @@ void WaylandInterface::switchToNextVirtualDesktop()
|
||||
int curPos = m_desktops.indexOf(m_currentDesktop);
|
||||
int nextPos = curPos + 1;
|
||||
|
||||
if (curPos == m_desktops.count()-1) {
|
||||
nextPos = 0;
|
||||
if (curPos >= m_desktops.count()-1) {
|
||||
if (isVirtualDesktopNavigationWrappingAround()) {
|
||||
nextPos = 0;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
KWayland::Client::PlasmaVirtualDesktop *desktopObj = m_virtualDesktopManagement->getVirtualDesktop(m_desktops[nextPos]);
|
||||
@ -350,8 +354,12 @@ void WaylandInterface::switchToPreviousVirtualDesktop()
|
||||
int curPos = m_desktops.indexOf(m_currentDesktop);
|
||||
int nextPos = curPos - 1;
|
||||
|
||||
if (curPos == 0) {
|
||||
nextPos = m_desktops.count()-1;
|
||||
if (curPos <= 0) {
|
||||
if (isVirtualDesktopNavigationWrappingAround()) {
|
||||
nextPos = m_desktops.count()-1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
KWayland::Client::PlasmaVirtualDesktop *desktopObj = m_virtualDesktopManagement->getVirtualDesktop(m_desktops[nextPos]);
|
||||
|
@ -180,7 +180,11 @@ void XWindowInterface::switchToNextVirtualDesktop()
|
||||
int nextPos = curPos + 1;
|
||||
|
||||
if (curPos == desktops) {
|
||||
nextPos = 1;
|
||||
if (isVirtualDesktopNavigationWrappingAround()) {
|
||||
nextPos = 1;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
KWindowSystem::setCurrentDesktop(nextPos);
|
||||
@ -197,7 +201,11 @@ void XWindowInterface::switchToPreviousVirtualDesktop()
|
||||
int nextPos = curPos - 1;
|
||||
|
||||
if (curPos == 1) {
|
||||
nextPos = desktops;
|
||||
if (isVirtualDesktopNavigationWrappingAround()) {
|
||||
nextPos = desktops;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
KWindowSystem::setCurrentDesktop(nextPos);
|
||||
|
Loading…
Reference in New Issue
Block a user