-
Notifications
You must be signed in to change notification settings - Fork 6
/
dbusinterface.h
304 lines (255 loc) · 9.14 KB
/
dbusinterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2012 Martin Gräßlin <[email protected]>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_DBUS_INTERFACE_H
#define KWIN_DBUS_INTERFACE_H
#include <QObject>
#include <QtDBus>
#include "utils.h"
#include "virtualdesktopsdbustypes.h"
namespace KWin
{
class Compositor;
class PluginManager;
class VirtualDesktopManager;
/**
* @brief This class is a wrapper for the org.kde.KWin D-Bus interface.
*
* The main purpose of this class is to be exported on the D-Bus as object /KWin.
* It is a pure wrapper to provide the deprecated D-Bus methods which have been
* removed from Workspace which used to implement the complete D-Bus interface.
*
* Nowadays the D-Bus interfaces are distributed, parts of it are exported on
* /Compositor, parts on /Effects and parts on /KWin. The implementation in this
* class just delegates the method calls to the actual implementation in one of the
* three singletons.
*
* @author Martin Gräßlin <[email protected]>
*/
class DBusInterface: public QObject, protected QDBusContext
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin")
public:
explicit DBusInterface(QObject *parent);
~DBusInterface() override;
public: // PROPERTIES
public Q_SLOTS: // METHODS
Q_NOREPLY void cascadeDesktop();
int currentDesktop();
Q_NOREPLY void killWindow();
void nextDesktop();
void previousDesktop();
Q_NOREPLY void reconfigure();
bool setCurrentDesktop(int desktop);
bool startActivity(const QString &in0);
bool stopActivity(const QString &in0);
QString supportInformation();
Q_NOREPLY void unclutterDesktop();
Q_NOREPLY void showDebugConsole();
Q_NOREPLY void replace();
QVariantMap queryWindowInfo();
QVariantMap getWindowInfo(const QString &uuid);
void setAppDefaultScale(qreal scale);
qreal getAppDefaultScale();
bool hasAlphaNumericKeyboard();
bool alwaysShowVirtualKeyboard();
void setAlwaysShowVirtualKeyboard(bool set);
void sendFakeKey(uint32_t keySym, uint32_t state);
void updateVKBRegion(double x, double y, double width, double height);
void updateVKRegion(int x, int y, int width, int height);
void updateVKBVisibility(bool visible);
void notifyVKStatus(bool visible);
int screenOrientation();
bool changeDownloadWindowMode(int mode, int n);
bool isCapsOn();
void focusChanged(bool set);
private Q_SLOTS:
void becomeKWinService(const QString &service);
Q_SIGNALS:
void appDefaultScaleChanged(qreal scale);
void hasAlphaNumericKeyboardChanged(bool set);
void alwaysShowVirtualKeyboardChanged(bool set);
void mouseOnTopLeftConer();
void mouseOnTopRightConer();
void screenOrientationChanged(int);
void capsChanged(bool);
private:
void announceService();
bool m_vkbVisible = false;
QRectF m_blockVKBRect = QRect();
QString m_serviceName;
bool m_alwaysShowVirtualKeyboard = false;
QDBusMessage m_replyQueryWindowInfo;
};
class CompositorDBusInterface : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Compositing")
/**
* @brief Whether the Compositor is active. That is a Scene is present and the Compositor is
* not shutting down itself.
*/
Q_PROPERTY(bool active READ isActive)
/**
* @brief Whether compositing is possible. Mostly means whether the required X extensions
* are available.
*/
Q_PROPERTY(bool compositingPossible READ isCompositingPossible)
/**
* @brief The reason why compositing is not possible. Empty String if compositing is possible.
*/
Q_PROPERTY(QString compositingNotPossibleReason READ compositingNotPossibleReason)
/**
* @brief Whether OpenGL has failed badly in the past (crash) and is considered as broken.
*/
Q_PROPERTY(bool openGLIsBroken READ isOpenGLBroken)
/**
* The type of the currently used Scene:
* @li @c none No Compositing
* @li @c xrender XRender
* @li @c gl1 OpenGL 1
* @li @c gl2 OpenGL 2
* @li @c gles OpenGL ES 2
*/
Q_PROPERTY(QString compositingType READ compositingType)
/**
* @brief All currently supported OpenGLPlatformInterfaces.
*
* Possible values:
* @li glx
* @li egl
*
* Values depend on operation mode and compile time options.
*/
Q_PROPERTY(QStringList supportedOpenGLPlatformInterfaces READ supportedOpenGLPlatformInterfaces)
Q_PROPERTY(bool platformRequiresCompositing READ platformRequiresCompositing)
public:
explicit CompositorDBusInterface(Compositor *parent);
~CompositorDBusInterface() override = default;
bool isActive() const;
bool isCompositingPossible() const;
QString compositingNotPossibleReason() const;
bool isOpenGLBroken() const;
QString compositingType() const;
QStringList supportedOpenGLPlatformInterfaces() const;
bool platformRequiresCompositing() const;
public Q_SLOTS:
/**
* @brief Suspends the Compositor if it is currently active.
*
* Note: it is possible that the Compositor is not able to suspend. Use isActive to check
* whether the Compositor has been suspended.
*
* @return void
* @see resume
* @see isActive
*/
void suspend();
/**
* @brief Resumes the Compositor if it is currently suspended.
*
* Note: it is possible that the Compositor cannot be resumed, that is there might be Clients
* blocking the usage of Compositing or the Scene might be broken. Use isActive to check
* whether the Compositor has been resumed. Also check isCompositingPossible and
* isOpenGLBroken.
*
* Note: The starting of the Compositor can require some time and is partially done threaded.
* After this method returns the setup may not have been completed.
*
* @return void
* @see suspend
* @see isActive
* @see isCompositingPossible
* @see isOpenGLBroken
*/
void resume();
/**
* @brief Used by Compositing KCM after settings change.
*
* On signal Compositor reloads settings and restarts.
*/
void reinitialize();
Q_SIGNALS:
void compositingToggled(bool active);
private:
Compositor *m_compositor;
};
//TODO: disable all of this in case of kiosk?
class VirtualDesktopManagerDBusInterface : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.VirtualDesktopManager")
/**
* The number of virtual desktops currently available.
* The ids of the virtual desktops are in the range [1, VirtualDesktopManager::maximum()].
*/
Q_PROPERTY(uint count READ count NOTIFY countChanged)
/**
* The number of rows the virtual desktops will be laid out in
*/
Q_PROPERTY(uint rows READ rows WRITE setRows NOTIFY rowsChanged)
/**
* The id of the virtual desktop which is currently in use.
*/
Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged)
/**
* Whether navigation in the desktop layout wraps around at the borders.
*/
Q_PROPERTY(bool navigationWrappingAround READ isNavigationWrappingAround WRITE setNavigationWrappingAround NOTIFY navigationWrappingAroundChanged)
/**
* list of key/value pairs which every one of them is representing a desktop
*/
Q_PROPERTY(KWin::DBusDesktopDataVector desktops READ desktops NOTIFY desktopsChanged);
public:
VirtualDesktopManagerDBusInterface(VirtualDesktopManager *parent);
~VirtualDesktopManagerDBusInterface() override = default;
uint count() const;
void setRows(uint rows);
uint rows() const;
void setCurrent(const QString &id);
QString current() const;
void setNavigationWrappingAround(bool wraps);
bool isNavigationWrappingAround() const;
KWin::DBusDesktopDataVector desktops() const;
Q_SIGNALS:
void countChanged(uint count);
void rowsChanged(uint rows);
void currentChanged(const QString &id);
void navigationWrappingAroundChanged(bool wraps);
void desktopsChanged(KWin::DBusDesktopDataVector);
void desktopDataChanged(const QString &id, KWin::DBusDesktopDataStruct);
void desktopCreated(const QString &id, KWin::DBusDesktopDataStruct);
void desktopRemoved(const QString &id);
public Q_SLOTS:
/**
* Create a desktop with a new name at a given position
* note: the position starts from 1
*/
void createDesktop(uint position, const QString &name);
void setDesktopName(const QString &id, const QString &name);
void removeDesktop(const QString &id);
private:
VirtualDesktopManager *m_manager;
};
class PluginManagerDBusInterface : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.Plugins")
Q_PROPERTY(QStringList LoadedPlugins READ loadedPlugins)
Q_PROPERTY(QStringList AvailablePlugins READ availablePlugins)
public:
explicit PluginManagerDBusInterface(PluginManager *manager);
QStringList loadedPlugins() const;
QStringList availablePlugins() const;
public Q_SLOTS:
bool LoadPlugin(const QString &name);
void UnloadPlugin(const QString &name);
private:
PluginManager *m_manager;
};
} // namespace
#endif // KWIN_DBUS_INTERFACE_H