Changeset View
Changeset View
Standalone View
Standalone View
libtaskmanager/virtualdesktopinfo.h
Show All 23 Lines | |||||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | 25 | | |||
26 | #include "taskmanager_export.h" | 26 | #include "taskmanager_export.h" | ||
27 | 27 | | |||
28 | namespace TaskManager | 28 | namespace TaskManager | ||
29 | { | 29 | { | ||
30 | 30 | | |||
31 | /** | 31 | /** | ||
32 | * @short Provides basic virtual desktop information. | 32 | * @short Provides basic virtual desktop information. The underlying windowing | ||
33 | * system is abstracted away. | ||||
33 | * | 34 | * | ||
34 | * This class provides basic information about the virtual desktops present | 35 | * This class provides basic information about the virtual desktops present | ||
35 | * in the session as a set of notifiable properties. | 36 | * in the session as a set of notifiable properties. | ||
36 | * | 37 | * | ||
37 | * @NOTE: This is a placeholder, to be moved into KWindowSystem (which it | | |||
38 | * wraps) or the Task Manager applet backend (which used to fill this role | | |||
39 | * in the past). | | |||
40 | * | | |||
41 | * @see KWindowSystem | | |||
42 | * | | |||
43 | * @author Eike Hein <hein@kde.org> | 38 | * @author Eike Hein <hein@kde.org> | ||
44 | **/ | 39 | **/ | ||
45 | 40 | | |||
46 | class TASKMANAGER_EXPORT VirtualDesktopInfo : public QObject | 41 | class TASKMANAGER_EXPORT VirtualDesktopInfo : public QObject | ||
47 | { | 42 | { | ||
48 | Q_OBJECT | 43 | Q_OBJECT | ||
49 | 44 | | |||
50 | Q_PROPERTY(int currentDesktop READ currentDesktop NOTIFY currentDesktopChanged) | 45 | Q_PROPERTY(QVariant currentDesktop READ currentDesktop NOTIFY currentDesktopChanged) | ||
51 | Q_PROPERTY(int numberOfDesktops READ numberOfDesktops NOTIFY numberOfDesktopsChanged) | 46 | Q_PROPERTY(int numberOfDesktops READ numberOfDesktops NOTIFY numberOfDesktopsChanged) | ||
47 | Q_PROPERTY(QVariantList desktopIds READ desktopIds NOTIFY desktopIdsChanged) | ||||
52 | Q_PROPERTY(QStringList desktopNames READ desktopNames NOTIFY desktopNamesChanged) | 48 | Q_PROPERTY(QStringList desktopNames READ desktopNames NOTIFY desktopNamesChanged) | ||
53 | Q_PROPERTY(int desktopLayoutRows READ desktopLayoutRows NOTIFY desktopLayoutRowsChanged) | 49 | Q_PROPERTY(int desktopLayoutRows READ desktopLayoutRows NOTIFY desktopLayoutRowsChanged) | ||
54 | 50 | | |||
55 | public: | 51 | public: | ||
56 | explicit VirtualDesktopInfo(QObject *parent = nullptr); | 52 | explicit VirtualDesktopInfo(QObject *parent = nullptr); | ||
57 | ~VirtualDesktopInfo() override; | 53 | ~VirtualDesktopInfo() override; | ||
58 | 54 | | |||
59 | /** | 55 | /** | ||
60 | * The currently active virtual desktop. | 56 | * The currently active virtual desktop. | ||
61 | * | 57 | * | ||
62 | * @returns the number of the currently active virtual desktop. | 58 | * @returns the id of the currently active virtual desktop. QString on | ||
59 | * Wayland; uint >0 on X11. | ||||
63 | **/ | 60 | **/ | ||
64 | int currentDesktop() const; | 61 | QVariant currentDesktop() const; | ||
65 | 62 | | |||
66 | /** | 63 | /** | ||
67 | * The number of virtual desktops present in the session. | 64 | * The number of virtual desktops present in the session. | ||
68 | * | 65 | * | ||
69 | * @returns the number of virtual desktops present in the session. | 66 | * @returns the number of virtual desktops present in the session. | ||
70 | **/ | 67 | **/ | ||
71 | int numberOfDesktops() const; | 68 | int numberOfDesktops() const; | ||
72 | 69 | | |||
73 | /** | 70 | /** | ||
74 | * The names of all virtual desktops present in the session. Note that | 71 | * The ids of all virtual desktops present in the session. | ||
75 | * virtual desktops are indexed starting at 1, so the name for virtual | 72 | * | ||
76 | * desktop 1 is at index 0 in this list. | 73 | * On Wayland, the ids are QString. On X11, they are uint >0. | ||
74 | * | ||||
75 | * @returns a the list of ids of the virtual desktops present in the | ||||
76 | * session. | ||||
77 | **/ | ||||
78 | QVariantList desktopIds() const; | ||||
79 | | ||||
80 | /** | ||||
81 | * The names of all virtual desktops present in the session. | ||||
82 | * | ||||
83 | * Note that on X11, virtual desktops are indexed starting at 1, so | ||||
84 | * the name for virtual desktop 1 is at index 0 in this list. | ||||
77 | * | 85 | * | ||
78 | * @returns a the list of names for the virtual desktops present in the | 86 | * @returns the list of names of the virtual desktops present in the | ||
79 | * session. | 87 | * session. | ||
80 | **/ | 88 | **/ | ||
81 | QStringList desktopNames() const; | 89 | QStringList desktopNames() const; | ||
82 | 90 | | |||
83 | /** | 91 | /** | ||
92 | * Returns the position of the passed-in virtual desktop. | ||||
93 | * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11). | ||||
94 | * @returns the position of the virtual desktop, or -1 if the desktop | ||||
95 | * id is not valid. | ||||
96 | **/ | ||||
97 | quint32 position(const QVariant &desktop) const; | ||||
98 | | ||||
99 | /** | ||||
84 | * The number of rows in the virtual desktop layout. | 100 | * The number of rows in the virtual desktop layout. | ||
85 | * | 101 | * | ||
86 | * @returns the number of rows in the virtual desktop layout. | 102 | * @returns the number of rows in the virtual desktop layout. | ||
87 | **/ | 103 | **/ | ||
88 | int desktopLayoutRows() const; | 104 | int desktopLayoutRows() const; | ||
89 | 105 | | |||
106 | /** | ||||
107 | * Request activating the passed-in virtual desktop. | ||||
108 | * | ||||
109 | * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11). | ||||
110 | **/ | ||||
111 | void requestActivate(const QVariant &desktop); | ||||
112 | | ||||
113 | /** | ||||
114 | * Request adding a new virtual desktop at the specified position. | ||||
115 | * | ||||
116 | * On X11, the position parameter is ignored and the new desktop is always | ||||
117 | * created at the end of the list. | ||||
118 | * | ||||
119 | * @param position The position of the requested new virtual desktop (ignored on X11). | ||||
120 | **/ | ||||
121 | void requestCreateDesktop(quint32 position); | ||||
122 | | ||||
123 | /** | ||||
124 | * Request removing the virtual desktop at the specified position. | ||||
125 | * | ||||
126 | * On X11, the position parameter is ignored and the last desktop in the list | ||||
127 | * is always the one removed. | ||||
128 | * | ||||
129 | * @param position The position of the virtual desktop to remove (ignored on X11). | ||||
130 | **/ | ||||
131 | void requestRemoveDesktop(quint32 position); | ||||
132 | | ||||
90 | Q_SIGNALS: | 133 | Q_SIGNALS: | ||
91 | void currentDesktopChanged() const; | 134 | void currentDesktopChanged() const; | ||
92 | void numberOfDesktopsChanged() const; | 135 | void numberOfDesktopsChanged() const; | ||
136 | void desktopIdsChanged() const; | ||||
93 | void desktopNamesChanged() const; | 137 | void desktopNamesChanged() const; | ||
94 | void desktopLayoutRowsChanged() const; | 138 | void desktopLayoutRowsChanged() const; | ||
139 | | ||||
140 | private: | ||||
141 | class Private; | ||||
142 | class XWindowPrivate; | ||||
143 | class WaylandPrivate; | ||||
144 | static Private *d; | ||||
95 | }; | 145 | }; | ||
96 | 146 | | |||
97 | } | 147 | } | ||
98 | 148 | | |||
99 | #endif | 149 | #endif |