Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/test_helpers.cpp
Show All 19 Lines | |||||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "shell_client.h" | 21 | #include "shell_client.h" | ||
22 | #include "screenlockerwatcher.h" | 22 | #include "screenlockerwatcher.h" | ||
23 | #include "wayland_server.h" | 23 | #include "wayland_server.h" | ||
24 | 24 | | |||
25 | #include <KWayland/Client/compositor.h> | 25 | #include <KWayland/Client/compositor.h> | ||
26 | #include <KWayland/Client/connection_thread.h> | 26 | #include <KWayland/Client/connection_thread.h> | ||
27 | #include <KWayland/Client/event_queue.h> | 27 | #include <KWayland/Client/event_queue.h> | ||
28 | #include <KWayland/Client/idleinhibit.h> | ||||
28 | #include <KWayland/Client/registry.h> | 29 | #include <KWayland/Client/registry.h> | ||
29 | #include <KWayland/Client/plasmashell.h> | 30 | #include <KWayland/Client/plasmashell.h> | ||
30 | #include <KWayland/Client/plasmawindowmanagement.h> | 31 | #include <KWayland/Client/plasmawindowmanagement.h> | ||
31 | #include <KWayland/Client/pointerconstraints.h> | 32 | #include <KWayland/Client/pointerconstraints.h> | ||
32 | #include <KWayland/Client/seat.h> | 33 | #include <KWayland/Client/seat.h> | ||
33 | #include <KWayland/Client/server_decoration.h> | 34 | #include <KWayland/Client/server_decoration.h> | ||
34 | #include <KWayland/Client/shell.h> | 35 | #include <KWayland/Client/shell.h> | ||
35 | #include <KWayland/Client/shm_pool.h> | 36 | #include <KWayland/Client/shm_pool.h> | ||
Show All 30 Lines | 59 | static struct { | |||
66 | ShmPool *shm = nullptr; | 67 | ShmPool *shm = nullptr; | ||
67 | Seat *seat = nullptr; | 68 | Seat *seat = nullptr; | ||
68 | PlasmaShell *plasmaShell = nullptr; | 69 | PlasmaShell *plasmaShell = nullptr; | ||
69 | PlasmaWindowManagement *windowManagement = nullptr; | 70 | PlasmaWindowManagement *windowManagement = nullptr; | ||
70 | PointerConstraints *pointerConstraints = nullptr; | 71 | PointerConstraints *pointerConstraints = nullptr; | ||
71 | Registry *registry = nullptr; | 72 | Registry *registry = nullptr; | ||
72 | QThread *thread = nullptr; | 73 | QThread *thread = nullptr; | ||
73 | QVector<Output*> outputs; | 74 | QVector<Output*> outputs; | ||
75 | IdleInhibitManager *idleInhibit = nullptr; | ||||
74 | } s_waylandConnection; | 76 | } s_waylandConnection; | ||
75 | 77 | | |||
76 | bool setupWaylandConnection(AdditionalWaylandInterfaces flags) | 78 | bool setupWaylandConnection(AdditionalWaylandInterfaces flags) | ||
77 | { | 79 | { | ||
78 | if (s_waylandConnection.connection) { | 80 | if (s_waylandConnection.connection) { | ||
79 | return false; | 81 | return false; | ||
80 | } | 82 | } | ||
81 | 83 | | |||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | |||||
182 | } | 184 | } | ||
183 | if (flags.testFlag(AdditionalWaylandInterface::PointerConstraints)) { | 185 | if (flags.testFlag(AdditionalWaylandInterface::PointerConstraints)) { | ||
184 | s_waylandConnection.pointerConstraints = registry->createPointerConstraints(registry->interface(Registry::Interface::PointerConstraintsUnstableV1).name, | 186 | s_waylandConnection.pointerConstraints = registry->createPointerConstraints(registry->interface(Registry::Interface::PointerConstraintsUnstableV1).name, | ||
185 | registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version); | 187 | registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version); | ||
186 | if (!s_waylandConnection.pointerConstraints->isValid()) { | 188 | if (!s_waylandConnection.pointerConstraints->isValid()) { | ||
187 | return false; | 189 | return false; | ||
188 | } | 190 | } | ||
189 | } | 191 | } | ||
192 | if (flags.testFlag(AdditionalWaylandInterface::IdleInhibition)) { | ||||
193 | s_waylandConnection.idleInhibit = registry->createIdleInhibitManager(registry->interface(Registry::Interface::IdleInhibitManagerUnstableV1).name, | ||||
194 | registry->interface(Registry::Interface::IdleInhibitManagerUnstableV1).version); | ||||
195 | if (!s_waylandConnection.idleInhibit->isValid()) { | ||||
196 | return false; | ||||
197 | } | ||||
198 | } | ||||
190 | 199 | | |||
191 | return true; | 200 | return true; | ||
192 | } | 201 | } | ||
193 | 202 | | |||
194 | void destroyWaylandConnection() | 203 | void destroyWaylandConnection() | ||
195 | { | 204 | { | ||
196 | delete s_waylandConnection.compositor; | 205 | delete s_waylandConnection.compositor; | ||
197 | s_waylandConnection.compositor = nullptr; | 206 | s_waylandConnection.compositor = nullptr; | ||
Show All 10 Lines | |||||
208 | delete s_waylandConnection.pointerConstraints; | 217 | delete s_waylandConnection.pointerConstraints; | ||
209 | s_waylandConnection.pointerConstraints = nullptr; | 218 | s_waylandConnection.pointerConstraints = nullptr; | ||
210 | delete s_waylandConnection.xdgShellV5; | 219 | delete s_waylandConnection.xdgShellV5; | ||
211 | s_waylandConnection.xdgShellV5 = nullptr; | 220 | s_waylandConnection.xdgShellV5 = nullptr; | ||
212 | delete s_waylandConnection.xdgShellV6; | 221 | delete s_waylandConnection.xdgShellV6; | ||
213 | s_waylandConnection.xdgShellV6 = nullptr; | 222 | s_waylandConnection.xdgShellV6 = nullptr; | ||
214 | delete s_waylandConnection.shell; | 223 | delete s_waylandConnection.shell; | ||
215 | s_waylandConnection.shell = nullptr; | 224 | s_waylandConnection.shell = nullptr; | ||
225 | delete s_waylandConnection.idleInhibit; | ||||
226 | s_waylandConnection.idleInhibit = nullptr; | ||||
216 | delete s_waylandConnection.shm; | 227 | delete s_waylandConnection.shm; | ||
217 | s_waylandConnection.shm = nullptr; | 228 | s_waylandConnection.shm = nullptr; | ||
218 | delete s_waylandConnection.queue; | 229 | delete s_waylandConnection.queue; | ||
219 | s_waylandConnection.queue = nullptr; | 230 | s_waylandConnection.queue = nullptr; | ||
220 | delete s_waylandConnection.registry; | 231 | delete s_waylandConnection.registry; | ||
221 | s_waylandConnection.registry = nullptr; | 232 | s_waylandConnection.registry = nullptr; | ||
222 | if (s_waylandConnection.thread) { | 233 | if (s_waylandConnection.thread) { | ||
223 | QSignalSpy spy(s_waylandConnection.connection, &QObject::destroyed); | 234 | QSignalSpy spy(s_waylandConnection.connection, &QObject::destroyed); | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 283 | { | |||
273 | return s_waylandConnection.windowManagement; | 284 | return s_waylandConnection.windowManagement; | ||
274 | } | 285 | } | ||
275 | 286 | | |||
276 | PointerConstraints *waylandPointerConstraints() | 287 | PointerConstraints *waylandPointerConstraints() | ||
277 | { | 288 | { | ||
278 | return s_waylandConnection.pointerConstraints; | 289 | return s_waylandConnection.pointerConstraints; | ||
279 | } | 290 | } | ||
280 | 291 | | |||
292 | IdleInhibitManager *waylandIdleInhibitManager() | ||||
293 | { | ||||
294 | return s_waylandConnection.idleInhibit; | ||||
295 | } | ||||
296 | | ||||
281 | bool waitForWaylandPointer() | 297 | bool waitForWaylandPointer() | ||
282 | { | 298 | { | ||
283 | if (!s_waylandConnection.seat) { | 299 | if (!s_waylandConnection.seat) { | ||
284 | return false; | 300 | return false; | ||
285 | } | 301 | } | ||
286 | QSignalSpy hasPointerSpy(s_waylandConnection.seat, &Seat::hasPointerChanged); | 302 | QSignalSpy hasPointerSpy(s_waylandConnection.seat, &Seat::hasPointerChanged); | ||
287 | if (!hasPointerSpy.isValid()) { | 303 | if (!hasPointerSpy.isValid()) { | ||
288 | return false; | 304 | return false; | ||
▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines |