KWayland

server_decoration_palette.h
1 /*
2  SPDX-FileCopyrightText: 2017 David Edmundson <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef KWAYLAND_CLIENT_SERVER_DECORATION_PALETTE_H
7 #define KWAYLAND_CLIENT_SERVER_DECORATION_PALETTE_H
8 
9 #include <QObject>
10 
11 #include <KWayland/Client/kwaylandclient_export.h>
12 
13 struct org_kde_kwin_server_decoration_palette_manager;
14 struct org_kde_kwin_server_decoration_palette;
15 
16 namespace KWayland
17 {
18 namespace Client
19 {
20 class EventQueue;
21 class Surface;
22 class ServerSideDecorationPalette;
23 
24 /**
25  * @short Wrapper for the org_kde_kwin_server_decoration_palette_manager interface.
26  *
27  * This class provides a convenient wrapper for the org_kde_kwin_server_decoration_palette_manager interface.
28  *
29  * To use this class one needs to interact with the Registry. There are two
30  * possible ways to create the ServerSideDecorationPaletteManager interface:
31  * @code
32  * ServerSideDecorationPaletteManager *c = registry->createServerSideDecorationPaletteManager(name, version);
33  * @endcode
34  *
35  * This creates the ServerSideDecorationPaletteManager and sets it up directly. As an alternative this
36  * can also be done in a more low level way:
37  * @code
38  * ServerSideDecorationPaletteManager *c = new ServerSideDecorationPaletteManager;
39  * c->setup(registry->bindServerSideDecorationPaletteManager(name, version));
40  * @endcode
41  *
42  * The ServerSideDecorationPaletteManager can be used as a drop-in replacement for any org_kde_kwin_server_decoration_palette_manager
43  * pointer as it provides matching cast operators.
44  *
45  * @see Registry
46  **/
47 class KWAYLANDCLIENT_EXPORT ServerSideDecorationPaletteManager : public QObject
48 {
49  Q_OBJECT
50 public:
51  /**
52  * Creates a new ServerSideDecorationPaletteManager.
53  * Note: after constructing the ServerSideDecorationPaletteManager it is not yet valid and one needs
54  * to call setup. In order to get a ready to use ServerSideDecorationPaletteManager prefer using
55  * Registry::createServerSideDecorationPaletteManager.
56  **/
57  explicit ServerSideDecorationPaletteManager(QObject *parent = nullptr);
59 
60  /**
61  * Setup this ServerSideDecorationPaletteManager to manage the @p serverSideDecorationPaletteManager.
62  * When using Registry::createServerSideDecorationPaletteManager there is no need to call this
63  * method.
64  **/
65  void setup(org_kde_kwin_server_decoration_palette_manager *serverSideDecorationPaletteManager);
66  /**
67  * @returns @c true if managing a org_kde_kwin_server_decoration_palette_manager.
68  **/
69  bool isValid() const;
70  /**
71  * Releases the org_kde_kwin_server_decoration_palette_manager interface.
72  * After the interface has been released the ServerSideDecorationPaletteManager instance is no
73  * longer valid and can be setup with another org_kde_kwin_server_decoration_palette_manager interface.
74  **/
75  void release();
76  /**
77  * Destroys the data held by this ServerSideDecorationPaletteManager.
78  * This method is supposed to be used when the connection to the Wayland
79  * server goes away. If the connection is not valid anymore, it's not
80  * possible to call release anymore as that calls into the Wayland
81  * connection and the call would fail. This method cleans up the data, so
82  * that the instance can be deleted or set up to a new org_kde_kwin_server_decoration_palette_manager interface
83  * once there is a new connection available.
84  *
85  * It is suggested to connect this method to ConnectionThread::connectionDied:
86  * @code
87  * connect(connection, &ConnectionThread::connectionDied, palettemanager, &ServerSideDecorationPaletteManager::destroy);
88  * @endcode
89  *
90  * @see release
91  **/
92  void destroy();
93 
94  /**
95  * Sets the @p queue to use for creating objects with this ServerSideDecorationPaletteManager.
96  **/
97  void setEventQueue(EventQueue *queue);
98  /**
99  * @returns The event queue to use for creating objects with this ServerSideDecorationPaletteManager.
100  **/
101  EventQueue *eventQueue();
102 
103  ServerSideDecorationPalette *create(Surface *surface, QObject *parent = nullptr);
104 
105  operator org_kde_kwin_server_decoration_palette_manager *();
106  operator org_kde_kwin_server_decoration_palette_manager *() const;
107 
108 Q_SIGNALS:
109  /**
110  * The corresponding global for this interface on the Registry got removed.
111  *
112  * This signal gets only emitted if the ServerSideDecorationPaletteManager got created by
113  * Registry::createServerSideDecorationPaletteManager
114  **/
115  void removed();
116 
117 private:
118  class Private;
120 };
121 
122 class KWAYLANDCLIENT_EXPORT ServerSideDecorationPalette : public QObject
123 {
124  Q_OBJECT
125 public:
126  virtual ~ServerSideDecorationPalette();
127 
128  /**
129  * Setup this ServerSideDecorationPalette to manage the @p serversidedecorationpalette.
130  * When using ServerSideDecorationPaletteManager::create there is no need to call this
131  * method.
132  **/
133  void setup(org_kde_kwin_server_decoration_palette *serversidedecorationpalette);
134  /**
135  * @returns @c true if managing a org_kde_kwin_server_decoration_palette.
136  **/
137  bool isValid() const;
138  /**
139  * Releases the org_kde_kwin_server_decoration_palette interface.
140  * After the interface has been released the ServerSideDecorationPalette instance is no
141  * longer valid and can be setup with another org_kde_kwin_server_decoration_palette interface.
142  **/
143  void release();
144  /**
145  * Destroys the data held by this ServerSideDecorationPalette.
146  * This method is supposed to be used when the connection to the Wayland
147  * server goes away. If the connection is not valid anymore, it's not
148  * possible to call release anymore as that calls into the Wayland
149  * connection and the call would fail. This method cleans up the data, so
150  * that the instance can be deleted or set up to a new org_kde_kwin_server_decoration_palette interface
151  * once there is a new connection available.
152  *
153  * It is suggested to connect this method to ConnectionThread::connectionDied:
154  * @code
155  * connect(connection, &ConnectionThread::connectionDied, palette, &ServerSideDecorationPalette::destroy);
156  * @endcode
157  *
158  * @see release
159  **/
160  void destroy();
161 
162  /**
163  * Sets the palette to be used by the server side decorations.
164  * Absolute file path, or name of palette in the user's config directory.
165  * If set to empty the default palette will be used.
166  */
167  void setPalette(const QString &palette);
168 
169  operator org_kde_kwin_server_decoration_palette *();
170  operator org_kde_kwin_server_decoration_palette *() const;
171 
172 private:
174  explicit ServerSideDecorationPalette(QObject *parent = nullptr);
175  class Private;
177 };
178 
179 }
180 }
181 
182 #endif
Wrapper for the org_kde_kwin_server_decoration_palette_manager interface.
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
Wrapper for the wl_surface interface.
Definition: surface.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Sep 23 2021 22:51:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.