KWayland

global.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef WAYLAND_SERVER_GLOBAL_H
7 #define WAYLAND_SERVER_GLOBAL_H
8 
9 #include <QObject>
10 
11 #include <KWayland/Server/kwaylandserver_export.h>
12 
13 struct wl_global;
14 
15 namespace KWayland
16 {
17 namespace Server
18 {
19 class Display;
20 
21 /**
22  * @brief Base class for all Globals.
23  *
24  * Any class representing a Global should be derived from this base class.
25  * This class provides common functionality for all globals. A global is an
26  * object listed as an interface on the registry on client side.
27  *
28  * Normally a Global gets factored by the Display. For each Global-derived class there
29  * is a dedicated factory method. After creating an instance through the factory method
30  * it is not yet announced on the registry. One needs to call ::create on it. This allows
31  * to setup the Global before it gets announced, ensuring that the client's state is correct
32  * from the start.
33  *
34  * As an example shown for @link OutputInterface @endlink:
35  * @code
36  * Display *display; // The existing display
37  * auto o = display->createOutput();
38  * o->setManufacturer(QStringLiteral("The KDE Community"));
39  * // setup further data on the OutputInterface
40  * o->create(); // announces OutputInterface
41  * @endcode
42  *
43  * @see Display
44  *
45  **/
46 class KWAYLANDSERVER_EXPORT Global : public QObject
47 {
48  Q_OBJECT
49 public:
50  virtual ~Global();
51  /**
52  * Creates the global by creating a native wl_global and by that announcing it
53  * to the clients.
54  **/
55  void create();
56  /**
57  * Destroys the low level wl_global. Afterwards the Global is no longer shown to clients.
58  **/
59  void destroy();
60  /**
61  * @returns whether the Global got created
62  **/
63  bool isValid() const;
64 
65  /**
66  * @returns the Display the Global got created on.
67  */
68  Display *display();
69 
70  /**
71  * Cast operator to the native wl_global this Global represents.
72  **/
73  operator wl_global*();
74  /**
75  * Cast operator to the native wl_global this Global represents.
76  **/
77  operator wl_global*() const;
78 
79 Q_SIGNALS:
80  /**
81  * This signal is emitted when the client is in the process of removing the wl_global.
82  * At the time the signal is emitted the global is still valid and allows to perform
83  * cleanup tasks.
84  */
85  void aboutToDestroyGlobal();
86 
87 protected:
88  class Private;
89  explicit Global(Private *d, QObject *parent = nullptr);
91 };
92 
93 }
94 }
95 
96 #endif
Class holding the Wayland server display loop.
Definition: display.h:89
Base class for all Globals.
Definition: global.h:46
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 22:51:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.