Changeset View
Changeset View
Standalone View
Standalone View
src/server/pointerconstraints_interface.h
- This file was added.
1 | /**************************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | ||||
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_SERVER_POINTERCONSTRAINTS_H | ||||
21 | #define KWAYLAND_SERVER_POINTERCONSTRAINTS_H | ||||
22 | | ||||
23 | #include "global.h" | ||||
24 | #include "resource.h" | ||||
25 | | ||||
26 | #include <KWayland/Server/kwaylandserver_export.h> | ||||
27 | | ||||
28 | #include <QRegion> | ||||
29 | | ||||
30 | namespace KWayland | ||||
31 | { | ||||
32 | namespace Server | ||||
33 | { | ||||
34 | | ||||
35 | class Display; | ||||
36 | class SurfaceInterface; | ||||
37 | | ||||
38 | /** | ||||
39 | * Enum describing the interface versions the PointerConstraintsInterface can support. | ||||
40 | * | ||||
41 | * @since 5.29 | ||||
42 | **/ | ||||
43 | enum class PointerConstraintsInterfaceVersion { | ||||
44 | /** | ||||
45 | * zwp_pointer_constraints_v1 | ||||
46 | **/ | ||||
47 | UnstableV1 | ||||
48 | }; | ||||
49 | | ||||
50 | /** | ||||
51 | * Manager object to create pointer constraints. | ||||
52 | * | ||||
53 | * To create this manager use @link{Display::createPointerConstraints} | ||||
54 | * | ||||
55 | * @see ConfinedPointerInterface | ||||
56 | * @see LockedPointerInterface | ||||
57 | * @see Display::createPointerConstraints | ||||
58 | * @since 5.29 | ||||
59 | **/ | ||||
60 | class KWAYLANDSERVER_EXPORT PointerConstraintsInterface : public Global | ||||
61 | { | ||||
62 | Q_OBJECT | ||||
63 | public: | ||||
64 | virtual ~PointerConstraintsInterface(); | ||||
65 | | ||||
66 | /** | ||||
67 | * @returns The interface version used by this PointerConstraintsInterface | ||||
68 | **/ | ||||
69 | PointerConstraintsInterfaceVersion interfaceVersion() const; | ||||
70 | | ||||
71 | protected: | ||||
72 | class Private; | ||||
73 | explicit PointerConstraintsInterface(Private *d, QObject *parent = nullptr); | ||||
74 | | ||||
75 | private: | ||||
76 | Private *d_func() const; | ||||
77 | }; | ||||
78 | | ||||
79 | /** | ||||
80 | * The LockedPointerInterface lets the client request to disable movements of | ||||
81 | * the virtual pointer (i.e. the cursor), effectively locking the pointer | ||||
82 | * to a position. | ||||
83 | * | ||||
84 | * It is up to the compositor whether the lock gets activated. | ||||
85 | * To activate it needs to use @link{LockedPointerInterface::setLocked}. | ||||
86 | * The compositor needs to ensure that the SurfaceInterface has pointer focus | ||||
87 | * and that the pointer is inside the @link{LockedPointerInterface::region} when | ||||
88 | * it activates the lock. | ||||
89 | * | ||||
90 | * While the lock is active the PointerInterface does no longer emit pointer motion | ||||
91 | * events, but still emits relative pointer motion events. | ||||
92 | * | ||||
93 | * @since 5.29 | ||||
94 | **/ | ||||
95 | class KWAYLANDSERVER_EXPORT LockedPointerInterface : public Resource | ||||
96 | { | ||||
97 | Q_OBJECT | ||||
98 | public: | ||||
99 | | ||||
100 | virtual ~LockedPointerInterface(); | ||||
101 | | ||||
102 | /** | ||||
103 | * @returns The interface version used by this LockedPointerInterface | ||||
104 | **/ | ||||
105 | PointerConstraintsInterfaceVersion interfaceVersion() const; | ||||
106 | | ||||
107 | enum class LifeTime { | ||||
108 | OneShot, | ||||
109 | Persistent | ||||
110 | }; | ||||
111 | | ||||
112 | LifeTime lifeTime() const; | ||||
113 | | ||||
114 | /** | ||||
115 | * The intersection of this region and the input region of the SurfaceInterface is used | ||||
116 | * to determine where the pointer must be in order for the lock to activate. | ||||
117 | * It is up to the compositor whether to warp the pointer or require some kind of | ||||
118 | * user interaction for the lock to activate. | ||||
119 | * | ||||
120 | * If the region is empty the SurfaceInterface input region is used. | ||||
121 | * | ||||
122 | * @see regionChanged | ||||
123 | * @see SurfaceInterface::input | ||||
124 | **/ | ||||
125 | QRegion region() const; | ||||
126 | | ||||
127 | /** | ||||
128 | * Whether the Compositor set this pointer lock to be active. | ||||
129 | * @see setLocked | ||||
130 | * @see lockedChanged | ||||
131 | **/ | ||||
132 | bool isLocked() const; | ||||
133 | | ||||
134 | /** | ||||
135 | * Activates or deactivates the lock. | ||||
136 | * | ||||
137 | * A pointer lock can only be activated if the SurfaceInterface | ||||
138 | * this LockedPointerInterface was created for has pointer focus | ||||
139 | * and the pointer is inside the @link{region}. | ||||
140 | * | ||||
141 | * @param locked Whether the lock should be active | ||||
142 | * @see isLocked | ||||
143 | * @see lockedChanged | ||||
144 | **/ | ||||
145 | void setLocked(bool locked); | ||||
146 | | ||||
147 | Q_SIGNALS: | ||||
148 | /** | ||||
149 | * Emitted whenever the region changes. | ||||
150 | * This happens when the parent SurfaceInterface gets committed | ||||
151 | * @see region | ||||
152 | **/ | ||||
153 | void regionChanged(); | ||||
154 | | ||||
155 | /** | ||||
156 | * Emitted whenever the @link{isLocked} state changes. | ||||
157 | * @see isLocked | ||||
158 | * @see setLocked | ||||
159 | **/ | ||||
160 | void lockedChanged(); | ||||
161 | | ||||
162 | protected: | ||||
163 | class Private; | ||||
164 | explicit LockedPointerInterface(Private *p, QObject *parent = nullptr); | ||||
165 | | ||||
166 | private: | ||||
167 | Private *d_func() const; | ||||
168 | friend class SurfaceInterface; | ||||
169 | }; | ||||
170 | | ||||
171 | /** | ||||
172 | * | ||||
173 | * The ConfinedPointerInterface gets installed on a SurfaceInterface. | ||||
174 | * The confinement indicates that the SurfaceInterface wants to confine the | ||||
175 | * pointer to a region of the SurfaceInterface. | ||||
176 | * | ||||
177 | * It is up to the compositor whether the confinement gets activated. | ||||
178 | * To activate it needs to use @link{ConfinedPointerInterface::setConfined}. | ||||
179 | * The compositor needs to ensure that the SurfaceInterface has pointer focus | ||||
180 | * and that the pointer is inside the @link{ConfinedPointerInterface::region} when | ||||
181 | * it activates the confinement. | ||||
182 | * | ||||
183 | * From client side the confinement gets deactivated by destroying the ConfinedPointerInterface. | ||||
184 | * From compositor side the confinement can be deactivated by setting | ||||
185 | * @link{ConfinedPointerInterface::setConfined} to @c false. | ||||
186 | * | ||||
187 | * @since 5.29 | ||||
188 | **/ | ||||
189 | class KWAYLANDSERVER_EXPORT ConfinedPointerInterface : public Resource | ||||
190 | { | ||||
191 | Q_OBJECT | ||||
192 | public: | ||||
193 | | ||||
194 | virtual ~ConfinedPointerInterface(); | ||||
195 | | ||||
196 | /** | ||||
197 | * @returns The interface version used by this ConfinedPointerInterface | ||||
198 | **/ | ||||
199 | PointerConstraintsInterfaceVersion interfaceVersion() const; | ||||
200 | | ||||
201 | enum class LifeTime { | ||||
202 | OneShot, | ||||
203 | Persistent | ||||
204 | }; | ||||
205 | | ||||
206 | LifeTime lifeTime() const; | ||||
207 | | ||||
208 | /** | ||||
209 | * The intersection of this region and the input region of the SurfaceInterface is used | ||||
210 | * to determine where the pointer must be in order for the confinement to activate. | ||||
211 | * It is up to the compositor whether to warp the pointer or require some kind of | ||||
212 | * user interaction for the confinement to activate. | ||||
213 | * | ||||
214 | * If the region is empty the SurfaceInterface input region is used. | ||||
215 | * | ||||
216 | * @see regionChanged | ||||
217 | * @see SurfaceInterface::input | ||||
218 | **/ | ||||
219 | QRegion region() const; | ||||
220 | | ||||
221 | /** | ||||
222 | * Whether the Compositor set this pointer confinement to be active. | ||||
223 | * @see setConfined | ||||
224 | * @see confinedChanged | ||||
225 | **/ | ||||
226 | bool isConfined() const; | ||||
227 | | ||||
228 | /** | ||||
229 | * Activates or deactivates the confinement. | ||||
230 | * | ||||
231 | * A pointer confinement can only be activated if the SurfaceInterface | ||||
232 | * this ConfinedPointerInterface was created for has pointer focus | ||||
233 | * and the pointer is inside the @link{region}. | ||||
234 | * | ||||
235 | * @param confined Whether the confinement should be active | ||||
236 | * @see isConfined | ||||
237 | * @see confinedChanged | ||||
238 | **/ | ||||
239 | void setConfined(bool confined); | ||||
240 | | ||||
241 | Q_SIGNALS: | ||||
242 | /** | ||||
243 | * Emitted whenever the region changes. | ||||
244 | * This happens when the parent SurfaceInterface gets committed | ||||
245 | * @see region | ||||
246 | **/ | ||||
247 | void regionChanged(); | ||||
248 | | ||||
249 | /** | ||||
250 | * Emitted whenever the @link{isConfined} state changes. | ||||
251 | * @see isConfined | ||||
252 | * @see setConfined | ||||
253 | **/ | ||||
254 | void confinedChanged(); | ||||
255 | | ||||
256 | protected: | ||||
257 | class Private; | ||||
258 | explicit ConfinedPointerInterface(Private *p, QObject *parent = nullptr); | ||||
259 | | ||||
260 | private: | ||||
261 | Private *d_func() const; | ||||
262 | friend class SurfaceInterface; | ||||
263 | }; | ||||
264 | | ||||
265 | } | ||||
266 | } | ||||
267 | | ||||
268 | #endif |