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

KDE's Doxygen guidelines are available online.