KWayland

display.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2018 David Edmundson <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #ifndef WAYLAND_SERVER_DISPLAY_H
8 #define WAYLAND_SERVER_DISPLAY_H
9 
10 #include <QList>
11 #include <QObject>
12 
13 #include <KWayland/Server/kwaylandserver_export.h>
14 
15 #include "clientconnection.h"
16 
17 struct wl_client;
18 struct wl_display;
19 struct wl_event_loop;
20 
21 namespace KWayland
22 {
23 /**
24  * @short KWayland Server.
25  *
26  * This namespace groups all classes related to the Server module.
27  *
28  * The main entry point into the KWayland::Server API is the Display class.
29  * It allows to create a Wayland server and create various global objects on it.
30  *
31  * KWayland::Server is an API to easily create a head-less Wayland server with a
32  * Qt style API.
33  *
34  * @see Display
35  **/
36 namespace Server
37 {
38 class CompositorInterface;
39 class DataDeviceManagerInterface;
40 class DpmsManagerInterface;
41 class IdleInterface;
43 class RemoteAccessManagerInterface;
44 class IdleInhibitManagerInterface;
45 class FakeInputInterface;
46 class OutputInterface;
47 class OutputDeviceInterface;
49 class PlasmaShellInterface;
50 class PlasmaWindowManagementInterface;
51 class QtSurfaceExtensionInterface;
52 class SeatInterface;
53 class ShadowManagerInterface;
54 class BlurManagerInterface;
55 class ContrastManagerInterface;
56 class ServerSideDecorationManagerInterface;
57 class SlideManagerInterface;
58 class ShellInterface;
59 class SubCompositorInterface;
60 enum class TextInputInterfaceVersion;
61 class TextInputManagerInterface;
62 enum class XdgShellInterfaceVersion;
63 class XdgShellInterface;
65 class RelativePointerManagerInterface;
67 class PointerGesturesInterface;
69 class PointerConstraintsInterface;
70 class XdgForeignInterface;
71 class AppMenuManagerInterface;
72 class ServerSideDecorationPaletteManagerInterface;
73 class PlasmaVirtualDesktopManagementInterface;
74 class XdgOutputManagerInterface;
75 class XdgDecorationManagerInterface;
76 class EglStreamControllerInterface;
77 class KeyStateInterface;
78 class LinuxDmabufUnstableV1Interface;
79 class TabletManagerInterface;
80 
81 /**
82  * @brief Class holding the Wayland server display loop.
83  *
84  * @todo Improve documentation
85  **/
86 class KWAYLANDSERVER_EXPORT Display : public QObject
87 {
88  Q_OBJECT
89  Q_PROPERTY(QString socketName READ socketName WRITE setSocketName NOTIFY socketNameChanged)
90  Q_PROPERTY(bool automaticSocketNaming READ automaticSocketNaming WRITE setAutomaticSocketNaming NOTIFY automaticSocketNamingChanged)
91  Q_PROPERTY(bool running READ isRunning NOTIFY runningChanged)
92 public:
93  explicit Display(QObject *parent = nullptr);
94  virtual ~Display();
95 
96  /**
97  * Sets the basename of the socket to @p name. If @p name is empty, it will use
98  * wl_display_add_socket_auto to get a free socket with a filename "wayland-%d".
99  **/
100  void setSocketName(const QString &name);
101  QString socketName() const;
102 
103  /**
104  * If automaticSocketNaming is true, the manually set socketName is ignored
105  * and it will use wl_display_add_socket_auto on start to get a free socket with
106  * a filename "wayland-%d" instead. The effective socket is written into socketName.
107  * @since 5.55
108  **/
109  void setAutomaticSocketNaming(bool automaticSocketNaming);
110  bool automaticSocketNaming() const;
111 
112  quint32 serial();
113  quint32 nextSerial();
114 
115  /**
116  * How to setup the server connection.
117  * @li ConnectToSocket: the server will open the socket identified by the socket name
118  * @li ConnectClientsOnly: only connections through createClient are possible
119  **/
120  enum class StartMode {
121  ConnectToSocket,
122  ConnectClientsOnly,
123  };
124  void start(StartMode mode = StartMode::ConnectToSocket);
125  void terminate();
126  /**
127  * Starts the event loop for the server socket.
128  * This method should only be used if start() is used before creating the
129  * QCoreApplication. In that case start() cannot fully setup the event processing
130  * and the loop needs to be started after the QCoreApplication got created.
131  * @see start
132  * @see dispatchEvents
133  **/
134  void startLoop();
135  /**
136  * Dispatches pending events in a blocking way. May only be used if the Display is
137  * created and started before the QCoreApplication is created. Once the QCoreApplication
138  * is created and the event loop is started this method delegates to the normal dispatch
139  * handling.
140  * @see startLoop
141  **/
142  void dispatchEvents(int msecTimeout = -1);
143 
144  /**
145  * Create a client for the given file descriptor.
146  *
147  * The client is created as if it connected through the normal server
148  * socket. This method can be used to create a connection bypassing the
149  * normal socket connection. It's recommended to use together with
150  * socketpair and pass the other side of the socket to the client.
151  *
152  * @param fd The file descriptor for the socket to the client
153  * @returns The new ClientConnection or @c null on failure.
154  **/
155  ClientConnection *createClient(int fd);
156 
157  operator wl_display *();
158  operator wl_display *() const;
159  bool isRunning() const;
160 
161  OutputInterface *createOutput(QObject *parent = nullptr);
162  void removeOutput(OutputInterface *output);
163  QList<OutputInterface *> outputs() const;
164 
165  OutputDeviceInterface *createOutputDevice(QObject *parent = nullptr);
166  void removeOutputDevice(OutputDeviceInterface *output);
167  QList<OutputDeviceInterface *> outputDevices() const;
168 
169  CompositorInterface *createCompositor(QObject *parent = nullptr);
170  void createShm();
171  ShellInterface *createShell(QObject *parent = nullptr);
172  SeatInterface *createSeat(QObject *parent = nullptr);
173  /**
174  * @returns All SeatInterface currently managed on the Display.
175  * @since 5.6
176  **/
177  QVector<SeatInterface *> seats() const;
178  SubCompositorInterface *createSubCompositor(QObject *parent = nullptr);
179  DataDeviceManagerInterface *createDataDeviceManager(QObject *parent = nullptr);
180  OutputManagementInterface *createOutputManagement(QObject *parent = nullptr);
181  PlasmaShellInterface *createPlasmaShell(QObject *parent = nullptr);
182  PlasmaWindowManagementInterface *createPlasmaWindowManagement(QObject *parent = nullptr);
183  QtSurfaceExtensionInterface *createQtSurfaceExtension(QObject *parent = nullptr);
184  IdleInterface *createIdle(QObject *parent = nullptr);
185  RemoteAccessManagerInterface *createRemoteAccessManager(QObject *parent = nullptr);
186  FakeInputInterface *createFakeInput(QObject *parent = nullptr);
187  ShadowManagerInterface *createShadowManager(QObject *parent = nullptr);
188  BlurManagerInterface *createBlurManager(QObject *parent = nullptr);
189  ContrastManagerInterface *createContrastManager(QObject *parent = nullptr);
190  SlideManagerInterface *createSlideManager(QObject *parent = nullptr);
191  DpmsManagerInterface *createDpmsManager(QObject *parent = nullptr);
192 
193  /** @since 5.60 */
194  KeyStateInterface *createKeyStateInterface(QObject *parent = nullptr);
195 
196  /**
197  * @since 5.6
198  **/
199  ServerSideDecorationManagerInterface *createServerSideDecorationManager(QObject *parent = nullptr);
200  /**
201  * Create the text input manager in interface @p version.
202  * @returns The created manager object
203  * @since 5.23
204  **/
205  TextInputManagerInterface *createTextInputManager(const TextInputInterfaceVersion &version, QObject *parent = nullptr);
206 
207  /**
208  * Creates the XdgShell in interface @p version.
209  *
210  * @since 5.25
211  **/
212  XdgShellInterface *createXdgShell(const XdgShellInterfaceVersion &version, QObject *parent = nullptr);
213 
214  /**
215  * Creates the RelativePointerManagerInterface in interface @p version
216  *
217  * @returns The created manager object
218  * @since 5.28
219  **/
220  RelativePointerManagerInterface *createRelativePointerManager(const RelativePointerInterfaceVersion &version, QObject *parent = nullptr);
221 
222  /**
223  * Creates the PointerGesturesInterface in interface @p version
224  *
225  * @returns The created manager object
226  * @since 5.29
227  **/
228  PointerGesturesInterface *createPointerGestures(const PointerGesturesInterfaceVersion &version, QObject *parent = nullptr);
229 
230  /**
231  * Creates the PointerConstraintsInterface in interface @p version
232  *
233  * @returns The created manager object
234  * @since 5.29
235  **/
236  PointerConstraintsInterface *createPointerConstraints(const PointerConstraintsInterfaceVersion &version, QObject *parent = nullptr);
237 
238  /**
239  * Creates the XdgForeignInterface in interface @p version
240  *
241  * @returns The created manager object
242  * @since 5.40
243  **/
244  XdgForeignInterface *createXdgForeignInterface(QObject *parent = nullptr);
245 
246  /**
247  * Creates the IdleInhibitManagerInterface in interface @p version.
248  *
249  * @returns The created manager object
250  * @since 5.41
251  **/
252  IdleInhibitManagerInterface *createIdleInhibitManager(const IdleInhibitManagerInterfaceVersion &version, QObject *parent = nullptr);
253 
254  /**
255  * Creates the AppMenuManagerInterface in interface @p version.
256  *
257  * @returns The created manager object
258  * @since 5.42
259  **/
260  AppMenuManagerInterface *createAppMenuManagerInterface(QObject *parent = nullptr);
261 
262  /**
263  * Creates the ServerSideDecorationPaletteManagerInterface in interface @p version.
264  *
265  * @returns The created manager object
266  * @since 5.42
267  **/
268  ServerSideDecorationPaletteManagerInterface *createServerSideDecorationPaletteManager(QObject *parent = nullptr);
269 
270  /**
271  * Creates the LinuxDmabufUnstableV1Interface in interface @p version.
272  *
273  * @returns A pointer to the created interface
274  **/
275  LinuxDmabufUnstableV1Interface *createLinuxDmabufInterface(QObject *parent = nullptr);
276 
277  /**
278  * Creates the XdgOutputManagerInterface
279  *
280  * @return the created manager
281  * @since 5.47
282  */
283  XdgOutputManagerInterface *createXdgOutputManager(QObject *parent = nullptr);
284 
285  /**
286  * Creates the PlasmaVirtualDesktopManagementInterface in interface @p version.
287  *
288  * @returns The created manager object
289  * @since 5.52
290  **/
291  PlasmaVirtualDesktopManagementInterface *createPlasmaVirtualDesktopManagement(QObject *parent = nullptr);
292 
293  /**
294  * Creates the XdgDecorationManagerInterface
295  * @arg shellInterface A created XdgShellInterface based on XDG_WM_BASE
296  *
297  * @return the created manager
298  * @since 5.54
299  */
300  XdgDecorationManagerInterface *createXdgDecorationManager(XdgShellInterface *shellInterface, QObject *parent = nullptr);
301 
302  /**
303  * Creates the EglStreamControllerInterface
304  *
305  * @return the created EGL Stream controller
306  * @since 5.58
307  */
308  EglStreamControllerInterface *createEglStreamControllerInterface(QObject *parent = nullptr);
309 
310  /**
311  * Creates the entry point to support wacom-like tablets and pens.
312  *
313  * @since 5.67
314  */
315  TabletManagerInterface *createTabletManagerInterface(QObject *parent = nullptr);
316 
317  /**
318  * Gets the ClientConnection for the given @p client.
319  * If there is no ClientConnection yet for the given @p client, it will be created.
320  * @param client The native client for which the ClientConnection is retrieved
321  * @return The ClientConnection for the given native client
322  **/
323  ClientConnection *getConnection(wl_client *client);
324  QVector<ClientConnection *> connections() const;
325 
326  /**
327  * Set the EGL @p display for this Wayland display.
328  * The EGLDisplay can only be set once and must be alive as long as the Wayland display
329  * is alive. The user should have set up the binding between the EGLDisplay and the
330  * Wayland display prior to calling this method.
331  *
332  * @see eglDisplay
333  * @since 5.3
334  **/
335  void setEglDisplay(void *display);
336  /**
337  * @returns the EGLDisplay used for this Wayland display or EGL_NO_DISPLAY if not set.
338  * @see setEglDisplay
339  * @since 5.3
340  **/
341  void *eglDisplay() const;
342 
343 Q_SIGNALS:
344  void socketNameChanged(const QString &);
345  void automaticSocketNamingChanged(bool);
346  void runningChanged(bool);
347  void aboutToTerminate();
348  void clientConnected(KWayland::Server::ClientConnection *);
349  void clientDisconnected(KWayland::Server::ClientConnection *);
350 
351 private:
352  class Private;
354 };
355 
356 }
357 }
358 
359 #endif
StartMode
How to setup the server connection.
Definition: display.h:120
Global for the org_kde_plasma_shell interface.
PointerConstraintsInterfaceVersion
Enum describing the interface versions the PointerConstraintsInterface can support.
Represents the global zpw_linux_dmabuf_v1 interface.
Global for server side Display Power Management Signaling interface.
The IdleInhibitorManagerInterface is used by clients to inhibit idle on a SurfaceInterface.
Manager to create ServerSideDecorationInterface.
Represents the Global for wl_data_device_manager interface.
PointerGesturesInterfaceVersion
Enum describing the interface versions the PointerGesturesInterface can support.
Represents the Global for the wl_eglstream_controller interface.
Global for the wl_output interface.
TextInputInterfaceVersion
Enum describing the different InterfaceVersion encapsulated in this implementation.
Represents a Seat on the Wayland Display.
The XdgDecorationManagerInterface class.
XdgShellInterfaceVersion
Enum describing the different InterfaceVersion encapsulated in this implementation.
Class holding the Wayland server display loop.
Definition: display.h:86
Represents the Global for org_kde_kwin_contrast_manager interface.
Represents the Global for org_kde_kwin_blur_manager interface.
Represents the Global for wl_compositor interface.
Manager object to create relative pointer interfaces.
Represent the Global for the interface.
Wrapper for the org_kde_plasma_virtual_desktop_management interface.
Represents an output device, the difference to Output is that this output can be disabled, so not currently used to display content.
Global representing the org_kde_kwin_idle interface.
This class encapsulates the server side logic of the XdgForeign protocol.
Global for the wl_shell interface.
Convenient Class which represents a wl_client.
Manager object for the PointerGestures.
Provides the DBus service name and object path to a AppMenu DBus interface.
Allows a client to specify a preferred palette to use for server-side window decorations.
IdleInhibitManagerInterfaceVersion
Enum describing the interface versions the IdleInhibitManagerInterface can support.
Manager object to create pointer constraints.
Represents the Global for org_kde_kwin_fake_input interface.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Sep 23 2021 22:51:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.