Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/test_helpers.cpp
Show All 27 Lines | |||||
28 | #include <KWayland/Client/idleinhibit.h> | 28 | #include <KWayland/Client/idleinhibit.h> | ||
29 | #include <KWayland/Client/registry.h> | 29 | #include <KWayland/Client/registry.h> | ||
30 | #include <KWayland/Client/plasmashell.h> | 30 | #include <KWayland/Client/plasmashell.h> | ||
31 | #include <KWayland/Client/plasmawindowmanagement.h> | 31 | #include <KWayland/Client/plasmawindowmanagement.h> | ||
32 | #include <KWayland/Client/pointerconstraints.h> | 32 | #include <KWayland/Client/pointerconstraints.h> | ||
33 | #include <KWayland/Client/seat.h> | 33 | #include <KWayland/Client/seat.h> | ||
34 | #include <KWayland/Client/server_decoration.h> | 34 | #include <KWayland/Client/server_decoration.h> | ||
35 | #include <KWayland/Client/shadow.h> | 35 | #include <KWayland/Client/shadow.h> | ||
36 | #include <KWayland/Client/shell.h> | | |||
37 | #include <KWayland/Client/shm_pool.h> | 36 | #include <KWayland/Client/shm_pool.h> | ||
38 | #include <KWayland/Client/output.h> | 37 | #include <KWayland/Client/output.h> | ||
39 | #include <KWayland/Client/subcompositor.h> | 38 | #include <KWayland/Client/subcompositor.h> | ||
40 | #include <KWayland/Client/subsurface.h> | 39 | #include <KWayland/Client/subsurface.h> | ||
41 | #include <KWayland/Client/surface.h> | 40 | #include <KWayland/Client/surface.h> | ||
42 | #include <KWayland/Client/appmenu.h> | 41 | #include <KWayland/Client/appmenu.h> | ||
43 | #include <KWayland/Client/xdgshell.h> | 42 | #include <KWayland/Client/xdgshell.h> | ||
44 | #include <KWayland/Client/xdgdecoration.h> | 43 | #include <KWayland/Client/xdgdecoration.h> | ||
Show All 18 Lines | |||||
63 | 62 | | |||
64 | static struct { | 63 | static struct { | ||
65 | ConnectionThread *connection = nullptr; | 64 | ConnectionThread *connection = nullptr; | ||
66 | EventQueue *queue = nullptr; | 65 | EventQueue *queue = nullptr; | ||
67 | Compositor *compositor = nullptr; | 66 | Compositor *compositor = nullptr; | ||
68 | SubCompositor *subCompositor = nullptr; | 67 | SubCompositor *subCompositor = nullptr; | ||
69 | ServerSideDecorationManager *decoration = nullptr; | 68 | ServerSideDecorationManager *decoration = nullptr; | ||
70 | ShadowManager *shadowManager = nullptr; | 69 | ShadowManager *shadowManager = nullptr; | ||
71 | Shell *shell = nullptr; | | |||
72 | XdgShell *xdgShellV5 = nullptr; | 70 | XdgShell *xdgShellV5 = nullptr; | ||
73 | XdgShell *xdgShellV6 = nullptr; | 71 | XdgShell *xdgShellV6 = nullptr; | ||
74 | XdgShell *xdgShellStable = nullptr; | 72 | XdgShell *xdgShellStable = nullptr; | ||
75 | ShmPool *shm = nullptr; | 73 | ShmPool *shm = nullptr; | ||
76 | Seat *seat = nullptr; | 74 | Seat *seat = nullptr; | ||
77 | PlasmaShell *plasmaShell = nullptr; | 75 | PlasmaShell *plasmaShell = nullptr; | ||
78 | PlasmaWindowManagement *windowManagement = nullptr; | 76 | PlasmaWindowManagement *windowManagement = nullptr; | ||
79 | PointerConstraints *pointerConstraints = nullptr; | 77 | PointerConstraints *pointerConstraints = nullptr; | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 87 | { | |||
152 | s_waylandConnection.subCompositor = registry->createSubCompositor(registry->interface(Registry::Interface::SubCompositor).name, registry->interface(Registry::Interface::SubCompositor).version); | 150 | s_waylandConnection.subCompositor = registry->createSubCompositor(registry->interface(Registry::Interface::SubCompositor).name, registry->interface(Registry::Interface::SubCompositor).version); | ||
153 | if (!s_waylandConnection.subCompositor->isValid()) { | 151 | if (!s_waylandConnection.subCompositor->isValid()) { | ||
154 | return false; | 152 | return false; | ||
155 | } | 153 | } | ||
156 | s_waylandConnection.shm = registry->createShmPool(registry->interface(Registry::Interface::Shm).name, registry->interface(Registry::Interface::Shm).version); | 154 | s_waylandConnection.shm = registry->createShmPool(registry->interface(Registry::Interface::Shm).name, registry->interface(Registry::Interface::Shm).version); | ||
157 | if (!s_waylandConnection.shm->isValid()) { | 155 | if (!s_waylandConnection.shm->isValid()) { | ||
158 | return false; | 156 | return false; | ||
159 | } | 157 | } | ||
160 | s_waylandConnection.shell = registry->createShell(registry->interface(Registry::Interface::Shell).name, registry->interface(Registry::Interface::Shell).version); | | |||
161 | if (!s_waylandConnection.shell->isValid()) { | | |||
162 | return false; | | |||
163 | } | | |||
164 | s_waylandConnection.xdgShellV5 = registry->createXdgShell(registry->interface(Registry::Interface::XdgShellUnstableV5).name, registry->interface(Registry::Interface::XdgShellUnstableV5).version); | 158 | s_waylandConnection.xdgShellV5 = registry->createXdgShell(registry->interface(Registry::Interface::XdgShellUnstableV5).name, registry->interface(Registry::Interface::XdgShellUnstableV5).version); | ||
165 | if (!s_waylandConnection.xdgShellV5->isValid()) { | 159 | if (!s_waylandConnection.xdgShellV5->isValid()) { | ||
166 | return false; | 160 | return false; | ||
167 | } | 161 | } | ||
168 | s_waylandConnection.xdgShellV6 = registry->createXdgShell(registry->interface(Registry::Interface::XdgShellUnstableV6).name, registry->interface(Registry::Interface::XdgShellUnstableV6).version); | 162 | s_waylandConnection.xdgShellV6 = registry->createXdgShell(registry->interface(Registry::Interface::XdgShellUnstableV6).name, registry->interface(Registry::Interface::XdgShellUnstableV6).version); | ||
169 | if (!s_waylandConnection.xdgShellV6->isValid()) { | 163 | if (!s_waylandConnection.xdgShellV6->isValid()) { | ||
170 | return false; | 164 | return false; | ||
171 | } | 165 | } | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 235 | { | |||
256 | delete s_waylandConnection.pointerConstraints; | 250 | delete s_waylandConnection.pointerConstraints; | ||
257 | s_waylandConnection.pointerConstraints = nullptr; | 251 | s_waylandConnection.pointerConstraints = nullptr; | ||
258 | delete s_waylandConnection.xdgShellV5; | 252 | delete s_waylandConnection.xdgShellV5; | ||
259 | s_waylandConnection.xdgShellV5 = nullptr; | 253 | s_waylandConnection.xdgShellV5 = nullptr; | ||
260 | delete s_waylandConnection.xdgShellV6; | 254 | delete s_waylandConnection.xdgShellV6; | ||
261 | s_waylandConnection.xdgShellV6 = nullptr; | 255 | s_waylandConnection.xdgShellV6 = nullptr; | ||
262 | delete s_waylandConnection.xdgShellStable; | 256 | delete s_waylandConnection.xdgShellStable; | ||
263 | s_waylandConnection.xdgShellStable = nullptr; | 257 | s_waylandConnection.xdgShellStable = nullptr; | ||
264 | delete s_waylandConnection.shell; | | |||
265 | s_waylandConnection.shell = nullptr; | | |||
266 | delete s_waylandConnection.shadowManager; | 258 | delete s_waylandConnection.shadowManager; | ||
267 | s_waylandConnection.shadowManager = nullptr; | 259 | s_waylandConnection.shadowManager = nullptr; | ||
268 | delete s_waylandConnection.idleInhibit; | 260 | delete s_waylandConnection.idleInhibit; | ||
269 | s_waylandConnection.idleInhibit = nullptr; | 261 | s_waylandConnection.idleInhibit = nullptr; | ||
270 | delete s_waylandConnection.shm; | 262 | delete s_waylandConnection.shm; | ||
271 | s_waylandConnection.shm = nullptr; | 263 | s_waylandConnection.shm = nullptr; | ||
272 | delete s_waylandConnection.queue; | 264 | delete s_waylandConnection.queue; | ||
273 | s_waylandConnection.queue = nullptr; | 265 | s_waylandConnection.queue = nullptr; | ||
Show All 32 Lines | 297 | { | |||
306 | return s_waylandConnection.subCompositor; | 298 | return s_waylandConnection.subCompositor; | ||
307 | } | 299 | } | ||
308 | 300 | | |||
309 | ShadowManager *waylandShadowManager() | 301 | ShadowManager *waylandShadowManager() | ||
310 | { | 302 | { | ||
311 | return s_waylandConnection.shadowManager; | 303 | return s_waylandConnection.shadowManager; | ||
312 | } | 304 | } | ||
313 | 305 | | |||
314 | Shell *waylandShell() | | |||
315 | { | | |||
316 | return s_waylandConnection.shell; | | |||
317 | } | | |||
318 | | ||||
319 | ShmPool *waylandShmPool() | 306 | ShmPool *waylandShmPool() | ||
320 | { | 307 | { | ||
321 | return s_waylandConnection.shm; | 308 | return s_waylandConnection.shm; | ||
322 | } | 309 | } | ||
323 | 310 | | |||
324 | Seat *waylandSeat() | 311 | Seat *waylandSeat() | ||
325 | { | 312 | { | ||
326 | return s_waylandConnection.seat; | 313 | return s_waylandConnection.seat; | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 449 | { | |||
466 | auto s = s_waylandConnection.subCompositor->createSubSurface(surface, parentSurface, parent); | 453 | auto s = s_waylandConnection.subCompositor->createSubSurface(surface, parentSurface, parent); | ||
467 | if (!s->isValid()) { | 454 | if (!s->isValid()) { | ||
468 | delete s; | 455 | delete s; | ||
469 | return nullptr; | 456 | return nullptr; | ||
470 | } | 457 | } | ||
471 | return s; | 458 | return s; | ||
472 | } | 459 | } | ||
473 | 460 | | |||
474 | ShellSurface *createShellSurface(Surface *surface, QObject *parent) | | |||
475 | { | | |||
476 | if (!s_waylandConnection.shell) { | | |||
477 | return nullptr; | | |||
478 | } | | |||
479 | auto s = s_waylandConnection.shell->createSurface(surface, parent); | | |||
480 | if (!s->isValid()) { | | |||
481 | delete s; | | |||
482 | return nullptr; | | |||
483 | } | | |||
484 | return s; | | |||
485 | } | | |||
486 | | ||||
487 | XdgShellSurface *createXdgShellV5Surface(Surface *surface, QObject *parent, CreationSetup creationSetup) | 461 | XdgShellSurface *createXdgShellV5Surface(Surface *surface, QObject *parent, CreationSetup creationSetup) | ||
488 | { | 462 | { | ||
489 | if (!s_waylandConnection.xdgShellV5) { | 463 | if (!s_waylandConnection.xdgShellV5) { | ||
490 | return nullptr; | 464 | return nullptr; | ||
491 | } | 465 | } | ||
492 | auto s = s_waylandConnection.xdgShellV5->createSurface(surface, parent); | 466 | auto s = s_waylandConnection.xdgShellV5->createSurface(surface, parent); | ||
493 | if (!s->isValid()) { | 467 | if (!s->isValid()) { | ||
494 | delete s; | 468 | delete s; | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 536 | { | |||
563 | //wait for configure | 537 | //wait for configure | ||
564 | QSignalSpy configureRequestedSpy(shellPopup, &KWayland::Client::XdgShellPopup::configureRequested); | 538 | QSignalSpy configureRequestedSpy(shellPopup, &KWayland::Client::XdgShellPopup::configureRequested); | ||
565 | QVERIFY(configureRequestedSpy.isValid()); | 539 | QVERIFY(configureRequestedSpy.isValid()); | ||
566 | surface->commit(Surface::CommitFlag::None); | 540 | surface->commit(Surface::CommitFlag::None); | ||
567 | QVERIFY(configureRequestedSpy.wait()); | 541 | QVERIFY(configureRequestedSpy.wait()); | ||
568 | shellPopup->ackConfigure(configureRequestedSpy.last()[1].toInt()); | 542 | shellPopup->ackConfigure(configureRequestedSpy.last()[1].toInt()); | ||
569 | } | 543 | } | ||
570 | 544 | | |||
571 | 545 | KWayland::Client::XdgShellSurface *createXdgShellSurface(XdgShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent, CreationSetup creationSetup) | |||
572 | QObject *createShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent) | | |||
573 | { | | |||
574 | switch (type) { | | |||
575 | case ShellSurfaceType::WlShell: | | |||
576 | return createShellSurface(surface, parent); | | |||
577 | case ShellSurfaceType::XdgShellV5: | | |||
578 | return createXdgShellV5Surface(surface, parent, CreationSetup::CreateAndConfigure); | | |||
579 | case ShellSurfaceType::XdgShellV6: | | |||
580 | return createXdgShellV6Surface(surface, parent, CreationSetup::CreateAndConfigure); | | |||
581 | case ShellSurfaceType::XdgShellStable: | | |||
582 | return createXdgShellStableSurface(surface, parent, CreationSetup::CreateAndConfigure); | | |||
583 | default: | | |||
584 | Q_UNREACHABLE(); | | |||
585 | return nullptr; | | |||
586 | } | | |||
587 | } | | |||
588 | | ||||
589 | KWayland::Client::XdgShellSurface *createXdgShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent, CreationSetup creationSetup) | | |||
590 | { | 546 | { | ||
591 | switch (type) { | 547 | switch (type) { | ||
592 | case ShellSurfaceType::XdgShellV5: | 548 | case XdgShellSurfaceType::XdgShellV5: | ||
593 | return createXdgShellV5Surface(surface, parent, creationSetup); | 549 | return createXdgShellV5Surface(surface, parent, creationSetup); | ||
594 | case ShellSurfaceType::XdgShellV6: | 550 | case XdgShellSurfaceType::XdgShellV6: | ||
595 | return createXdgShellV6Surface(surface, parent, creationSetup); | 551 | return createXdgShellV6Surface(surface, parent, creationSetup); | ||
596 | case ShellSurfaceType::XdgShellStable: | 552 | case XdgShellSurfaceType::XdgShellStable: | ||
597 | return createXdgShellStableSurface(surface, parent, creationSetup); | 553 | return createXdgShellStableSurface(surface, parent, creationSetup); | ||
598 | default: | 554 | default: | ||
599 | return nullptr; | 555 | return nullptr; | ||
600 | } | 556 | } | ||
601 | } | 557 | } | ||
602 | 558 | | |||
603 | bool waitForWindowDestroyed(AbstractClient *client) | 559 | bool waitForWindowDestroyed(AbstractClient *client) | ||
604 | { | 560 | { | ||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |