Changeset View
Changeset View
Standalone View
Standalone View
src/client/remoteaccess.h
- This file was added.
1 | /**************************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2016 Oleg Chernovskiy <kanedias@xaker.ru> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | ****************************************************************************/ | ||||
20 | #ifndef KWAYLAND_CLIENT_KRFB_H | ||||
21 | #define KWAYLAND_CLIENT_KRFB_H | ||||
22 | | ||||
23 | #include <QObject> | ||||
24 | | ||||
25 | #include <KWayland/Client/kwaylandclient_export.h> | ||||
26 | | ||||
27 | struct org_kde_kwin_remoteaccess; | ||||
28 | | ||||
29 | namespace KWayland | ||||
30 | { | ||||
31 | namespace Client | ||||
32 | { | ||||
33 | | ||||
34 | class EventQueue; | ||||
35 | | ||||
36 | /** | ||||
37 | * @short Wrapper for the org_kde_kwin_remoteaccess interface. | ||||
38 | * | ||||
39 | * This class provides a convenient wrapper for the org_kde_kwin_remoteaccess interface. | ||||
40 | * | ||||
41 | * To use this class one needs to interact with the Registry. There are two | ||||
42 | * possible ways to create the RemoteAccess interface: | ||||
43 | * @code | ||||
44 | * RemoteAccess *c = registry->createRemoteAccess(name, version); | ||||
45 | * @endcode | ||||
46 | * | ||||
47 | * This creates the RemoteAccess and sets it up directly. As an alternative this | ||||
48 | * can also be done in a more low level way: | ||||
49 | * @code | ||||
50 | * RemoteAccess *c = new RemoteAccess; | ||||
51 | * c->setup(registry->bindRemoteAccess(name, version)); | ||||
52 | * @endcode | ||||
53 | * | ||||
54 | * The RemoteAccess can be used as a drop-in replacement for any org_kde_kwin_remoteaccess | ||||
55 | * pointer as it provides matching cast operators. | ||||
56 | * | ||||
57 | * @see Registry | ||||
58 | **/ | ||||
59 | class KWAYLANDCLIENT_EXPORT RemoteAccess : public QObject | ||||
60 | { | ||||
61 | Q_OBJECT | ||||
62 | public: | ||||
63 | /** | ||||
64 | * Creates a new RemoteAccess. | ||||
65 | * Note: after constructing the RemoteAccess it is not yet valid and one needs | ||||
66 | * to call setup. In order to get a ready to use RemoteAccess prefer using | ||||
67 | * Registry::createRemoteAccess. | ||||
68 | **/ | ||||
69 | explicit RemoteAccess(QObject *parent = nullptr); | ||||
70 | virtual ~RemoteAccess(); | ||||
71 | | ||||
72 | /** | ||||
73 | * Setup this RemoteAccess to manage the @p remoteaccess. | ||||
74 | * When using Registry::createRemoteAccess there is no need to call this | ||||
75 | * method. | ||||
76 | **/ | ||||
77 | void setup(org_kde_kwin_remoteaccess *remoteAccess); | ||||
78 | /** | ||||
79 | * @returns @c true if managing a org_kde_kwin_remoteaccess. | ||||
80 | **/ | ||||
81 | bool isValid() const; | ||||
82 | /** | ||||
83 | * Releases the org_kde_kwin_remoteaccess interface. | ||||
84 | * After the interface has been released the RemoteAccess instance is no | ||||
85 | * longer valid and can be setup with another org_kde_kwin_remoteaccess interface. | ||||
86 | **/ | ||||
87 | void release(); | ||||
88 | /** | ||||
89 | * Destroys the data held by this RemoteAccess. | ||||
90 | * This method is supposed to be used when the connection to the Wayland | ||||
91 | * server goes away. If the connection is not valid anymore, it's not | ||||
92 | * possible to call release anymore as that calls into the Wayland | ||||
93 | * connection and the call would fail. This method cleans up the data, so | ||||
94 | * that the instance can be deleted or set up to a new org_kde_kwin_remoteaccess interface | ||||
95 | * once there is a new connection available. | ||||
96 | * | ||||
97 | * It is suggested to connect this method to ConnectionThread::connectionDied: | ||||
98 | * @code | ||||
99 | * connect(connection, &ConnectionThread::connectionDied, remoteaccess, &RemoteAccess::destroy); | ||||
100 | * @endcode | ||||
101 | * | ||||
102 | * @see release | ||||
103 | **/ | ||||
104 | void destroy(); | ||||
105 | | ||||
106 | /** | ||||
107 | * Sets the @p queue to use for creating objects with this RemoteAccess. | ||||
108 | **/ | ||||
109 | void setEventQueue(EventQueue *queue); | ||||
110 | /** | ||||
111 | * @returns The event queue to use for creating objects with this RemoteAccess. | ||||
112 | **/ | ||||
113 | EventQueue *eventQueue(); | ||||
114 | | ||||
115 | void bufferNoLongerNeeded(); | ||||
116 | | ||||
117 | operator org_kde_kwin_remoteaccess*(); | ||||
118 | operator org_kde_kwin_remoteaccess*() const; | ||||
119 | | ||||
120 | Q_SIGNALS: | ||||
121 | /** | ||||
122 | * The corresponding global for this interface on the Registry got removed. | ||||
123 | * | ||||
124 | * This signal gets only emitted if the RemoteAccess got created by | ||||
125 | * Registry::createRemoteAccess | ||||
126 | **/ | ||||
127 | void removed(); | ||||
128 | void bufferReady(qint32 gbmHandle, quint32 width, quint32 height, quint32 stride, quint32 format); | ||||
129 | | ||||
130 | private: | ||||
131 | class Private; | ||||
132 | QScopedPointer<Private> d; | ||||
133 | }; | ||||
134 | | ||||
135 | | ||||
136 | } | ||||
137 | } | ||||
138 | | ||||
139 | #endif |