KWayland

remote_access.h
1 /*
2  SPDX-FileCopyrightText: 2016 Oleg Chernovskiy <[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_REMOTE_ACCESS_H
7 #define KWAYLAND_CLIENT_REMOTE_ACCESS_H
8 
9 #include <QObject>
10 
11 #include <KWayland/Client/kwaylandclient_export.h>
12 
13 struct org_kde_kwin_remote_access_manager;
14 struct org_kde_kwin_remote_buffer;
15 struct wl_output;
16 
17 namespace KWayland
18 {
19 namespace Client
20 {
21 class EventQueue;
22 class RemoteBuffer;
23 
24 /**
25  * @short Wrapper for the org_kde_kwin_remote_access_manager interface.
26  *
27  * This class provides a convenient wrapper for the org_kde_kwin_remote_access_manager interface.
28  *
29  * To use this class one needs to interact with the Registry. There are two
30  * possible ways to create the RemoteAccessManager interface:
31  * @code
32  * RemoteAccessManager *c = registry->createRemoteAccessManager(name, version);
33  * @endcode
34  *
35  * This creates the RemoteAccessManager and sets it up directly. As an alternative this
36  * can also be done in a more low level way:
37  * @code
38  * RemoteAccessManager *c = new RemoteAccessManager;
39  * c->setup(registry->bindRemoteAccessManager(name, version));
40  * @endcode
41  *
42  * The RemoteAccessManager can be used as a drop-in replacement for any org_kde_kwin_remote_access_manager
43  * pointer as it provides matching cast operators.
44  *
45  * @see Registry
46  **/
47 class KWAYLANDCLIENT_EXPORT RemoteAccessManager : public QObject
48 {
49  Q_OBJECT
50 public:
51  /**
52  * Creates a new RemoteAccessManager.
53  * Note: after constructing the RemoteAccessManager it is not yet valid and one needs
54  * to call setup. In order to get a ready to use RemoteAccessManager prefer using
55  * Registry::createRemoteAccessManager.
56  **/
57  explicit RemoteAccessManager(QObject *parent = nullptr);
58  virtual ~RemoteAccessManager();
59 
60  /**
61  * Setup this RemoteAccessManager to manage the @p remoteaccessmanager.
62  * When using Registry::createRemoteAccessManager there is no need to call this
63  * method.
64  **/
65  void setup(org_kde_kwin_remote_access_manager *remoteaccessmanager);
66  /**
67  * @returns @c true if managing a org_kde_kwin_remote_access_manager.
68  **/
69  bool isValid() const;
70  /**
71  * Releases the org_kde_kwin_remote_access_manager interface.
72  * After the interface has been released the RemoteAccessManager instance is no
73  * longer valid and can be setup with another org_kde_kwin_remote_access_manager interface.
74  **/
75  void release();
76  /**
77  * Destroys the data held by this RemoteAccessManager.
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_remote_access_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, remoteaccessmanager, &RemoteAccessManager::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 RemoteAccessManager.
96  **/
97  void setEventQueue(EventQueue *queue);
98  /**
99  * @returns The event queue to use for creating objects with this RemoteAccessManager.
100  **/
101  EventQueue *eventQueue();
102 
103  operator org_kde_kwin_remote_access_manager *();
104  operator org_kde_kwin_remote_access_manager *() const;
105 
106 Q_SIGNALS:
107  /**
108  * The corresponding global for this interface on the Registry got removed.
109  *
110  * This signal gets only emitted if the RemoteAccessManager got created by
111  * Registry::createRemoteAccessManager
112  **/
113  void removed();
114 
115  /**
116  * Buffer from server is ready to be delivered to this client
117  * @param buffer_id internal buffer id to be created
118  **/
119  void bufferReady(const void *output, const RemoteBuffer *rbuf);
120 
121 private:
122  class Private;
124 };
125 
126 /**
127  * @short Wrapper for org_kde_kwin_remote_buffer interface.
128  * The instances of this class are created by parent RemoteAccessManager.
129  * Deletion (by noLongerNeeded call) is in responsibility of underlying system.
130  */
131 class KWAYLANDCLIENT_EXPORT RemoteBuffer : public QObject
132 {
133  Q_OBJECT
134 public:
135  virtual ~RemoteBuffer();
136  /**
137  * Setup this RemoteBuffer to manage the @p remotebuffer.
138  **/
139  void setup(org_kde_kwin_remote_buffer *remotebuffer);
140  /**
141  * @returns @c true if managing a org_kde_kwin_remote_buffer.
142  **/
143  bool isValid() const;
144  /**
145  * Releases the org_kde_kwin_remote_buffer interface.
146  * After the interface has been released the RemoteBuffer instance is no
147  * longer valid and can be setup with another org_kde_kwin_remote_buffer interface.
148  **/
149  void release();
150  /**
151  * Destroys the data held by this RemoteBuffer.
152  * This method is supposed to be used when the connection to the Wayland
153  * server goes away. If the connection is not valid anymore, it's not
154  * possible to call release anymore as that calls into the Wayland
155  * connection and the call would fail. This method cleans up the data, so
156  * that the instance can be deleted or set up to a new org_kde_kwin_remote_buffer interface
157  * once there is a new connection available.
158  *
159  * It is suggested to connect this method to ConnectionThread::connectionDied:
160  * @code
161  * connect(connection, &ConnectionThread::connectionDied, remotebuffer, &RemoteBuffer::destroy);
162  * @endcode
163  *
164  * @see release
165  **/
166  void destroy();
167 
168  operator org_kde_kwin_remote_buffer *();
169  operator org_kde_kwin_remote_buffer *() const;
170 
171  qint32 fd() const;
172  quint32 width() const;
173  quint32 height() const;
174  quint32 stride() const;
175  quint32 format() const;
176 
177 Q_SIGNALS:
178  void parametersObtained();
179 
180 private:
181  friend class RemoteAccessManager;
182  explicit RemoteBuffer(QObject *parent = nullptr);
183  class Private;
185 };
186 
187 }
188 }
189 
190 #endif
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
Wrapper for the org_kde_kwin_remote_access_manager interface.
Definition: remote_access.h:47
Wrapper for org_kde_kwin_remote_buffer interface.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Sep 19 2021 22:51:12 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.