Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
VirtualDesktopManager.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include <phosphorworkspaces_export.h>
8#include <QHash>
9#include <QObject>
10#include <QString>
11#include <QStringList>
12
13class QDBusInterface;
14class QDBusMessage;
15
16namespace PhosphorWorkspaces {
17
18class PHOSPHORWORKSPACES_EXPORT VirtualDesktopManager : public QObject, public PhosphorEngine::IVirtualDesktopManager
19{
20 Q_OBJECT
21
22public:
23 explicit VirtualDesktopManager(QObject* parent = nullptr);
25
26 bool init();
27 void start();
28 void stop();
29
30 int currentDesktop() const override;
31 int currentDesktopForScreen(const QString& screenId) const override;
32 bool perScreenModeActive() const override;
33
39 void updateScreenDesktop(const QString& screenId, int desktop);
40
45 void removeScreenDesktop(const QString& screenId);
46
47 void setCurrentDesktop(int desktop);
48 int desktopCount() const;
52 int desktopRows() const;
53 QStringList desktopNames() const;
54
55Q_SIGNALS:
56 void currentDesktopChanged(int desktop);
57 void desktopCountChanged(int count);
62 void screenDesktopChanged(const QString& screenId, int desktop);
63
64private Q_SLOTS:
65 void onNumberOfDesktopsChanged(int count);
66 void refreshFromKWin();
67 void onKWinCurrentChanged(const QString& desktopId);
68 void onKWinDesktopCreated();
69 void onKWinDesktopRemoved();
70 void onKWinDesktopRowsChanged();
71
72private:
73 void initKWinDBus();
74 void applyDesktopListReply(const QDBusMessage& reply, const QString& currentId);
78 void clampScreenDesktopsToCount();
79
80 QDBusInterface* m_kwinVDInterface = nullptr;
81 bool m_running = false;
82 bool m_useKWinDBus = false;
83 int m_currentDesktop = 1;
87 QHash<QString, int> m_screenDesktops;
88 int m_desktopCount = 1;
89 int m_desktopRows = 1;
90 QStringList m_desktopNames;
91 QStringList m_desktopIds;
92 uint m_refreshGeneration = 0;
93};
94
95} // namespace PhosphorWorkspaces
Definition IVirtualDesktopManager.h:13
Definition VirtualDesktopManager.h:19
void removeScreenDesktop(const QString &screenId)
Drop a screen's recorded per-output desktop when the output is removed, so the map doesn't retain sta...
void screenDesktopChanged(const QString &screenId, int desktop)
A single screen's current virtual desktop changed (per-output virtual desktops).
VirtualDesktopManager(QObject *parent=nullptr)
int currentDesktop() const override
The global (active-screen) current virtual desktop, 1-based.
void updateScreenDesktop(const QString &screenId, int desktop)
Record a screen's current virtual desktop (1-based).
bool perScreenModeActive() const override
True when at least two screens are on different virtual desktops, i.e.
int currentDesktopForScreen(const QString &screenId) const override
The current virtual desktop for a specific screen, 1-based.
int desktopRows() const
Number of rows in KWin's virtual-desktop grid (>= 1).
Definition WindowTrackingService.h:46