Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show All 31 Lines | |||||
32 | #include "workspace.h" | 32 | #include "workspace.h" | ||
33 | #include "shell_client.h" | 33 | #include "shell_client.h" | ||
34 | #include <kwineffects.h> | 34 | #include <kwineffects.h> | ||
35 | 35 | | |||
36 | #include <KWayland/Client/buffer.h> | 36 | #include <KWayland/Client/buffer.h> | ||
37 | #include <KWayland/Client/connection_thread.h> | 37 | #include <KWayland/Client/connection_thread.h> | ||
38 | #include <KWayland/Client/compositor.h> | 38 | #include <KWayland/Client/compositor.h> | ||
39 | #include <KWayland/Client/pointer.h> | 39 | #include <KWayland/Client/pointer.h> | ||
40 | #include <KWayland/Client/shell.h> | | |||
41 | #include <KWayland/Client/seat.h> | 40 | #include <KWayland/Client/seat.h> | ||
42 | #include <KWayland/Client/server_decoration.h> | 41 | #include <KWayland/Client/server_decoration.h> | ||
43 | #include <KWayland/Client/shm_pool.h> | 42 | #include <KWayland/Client/shm_pool.h> | ||
44 | #include <KWayland/Client/surface.h> | 43 | #include <KWayland/Client/surface.h> | ||
45 | 44 | | |||
46 | #include <KWayland/Server/buffer_interface.h> | 45 | #include <KWayland/Server/buffer_interface.h> | ||
47 | #include <KWayland/Server/clientconnection.h> | 46 | #include <KWayland/Server/clientconnection.h> | ||
48 | #include <KWayland/Server/seat_interface.h> | 47 | #include <KWayland/Server/seat_interface.h> | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 103 | private Q_SLOTS: | |||
126 | void testPopup(); | 125 | void testPopup(); | ||
127 | void testDecoCancelsPopup(); | 126 | void testDecoCancelsPopup(); | ||
128 | void testWindowUnderCursorWhileButtonPressed(); | 127 | void testWindowUnderCursorWhileButtonPressed(); | ||
129 | void testConfineToScreenGeometry_data(); | 128 | void testConfineToScreenGeometry_data(); | ||
130 | void testConfineToScreenGeometry(); | 129 | void testConfineToScreenGeometry(); | ||
131 | void testResizeCursor_data(); | 130 | void testResizeCursor_data(); | ||
132 | void testResizeCursor(); | 131 | void testResizeCursor(); | ||
133 | void testMoveCursor(); | 132 | void testMoveCursor(); | ||
133 | void testHideShowCursor(); | ||||
134 | 134 | | |||
135 | private: | 135 | private: | ||
136 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | 136 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | ||
137 | KWayland::Client::Compositor *m_compositor = nullptr; | 137 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
138 | KWayland::Client::Seat *m_seat = nullptr; | 138 | KWayland::Client::Seat *m_seat = nullptr; | ||
139 | KWayland::Client::Shell *m_shell = nullptr; | | |||
140 | }; | 139 | }; | ||
141 | 140 | | |||
142 | void PointerInputTest::initTestCase() | 141 | void PointerInputTest::initTestCase() | ||
143 | { | 142 | { | ||
144 | qRegisterMetaType<KWin::ShellClient*>(); | 143 | qRegisterMetaType<KWin::ShellClient*>(); | ||
145 | qRegisterMetaType<KWin::AbstractClient*>(); | 144 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
146 | qRegisterMetaType<KWin::Deleted*>(); | 145 | qRegisterMetaType<KWin::Deleted*>(); | ||
147 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 146 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
Show All 22 Lines | |||||
170 | waylandServer()->initWorkspace(); | 169 | waylandServer()->initWorkspace(); | ||
171 | } | 170 | } | ||
172 | 171 | | |||
173 | void PointerInputTest::init() | 172 | void PointerInputTest::init() | ||
174 | { | 173 | { | ||
175 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration)); | 174 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration)); | ||
176 | QVERIFY(Test::waitForWaylandPointer()); | 175 | QVERIFY(Test::waitForWaylandPointer()); | ||
177 | m_compositor = Test::waylandCompositor(); | 176 | m_compositor = Test::waylandCompositor(); | ||
178 | m_shell = Test::waylandShell(); | | |||
179 | m_seat = Test::waylandSeat(); | 177 | m_seat = Test::waylandSeat(); | ||
180 | 178 | | |||
181 | screens()->setCurrent(0); | 179 | screens()->setCurrent(0); | ||
182 | Cursor::setPos(QPoint(640, 512)); | 180 | Cursor::setPos(QPoint(640, 512)); | ||
183 | } | 181 | } | ||
184 | 182 | | |||
185 | void PointerInputTest::cleanup() | 183 | void PointerInputTest::cleanup() | ||
186 | { | 184 | { | ||
Show All 19 Lines | 195 | { | |||
206 | QSignalSpy leftSpy(pointer, &Pointer::left); | 204 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||
207 | QVERIFY(leftSpy.isValid()); | 205 | QVERIFY(leftSpy.isValid()); | ||
208 | 206 | | |||
209 | // create a window | 207 | // create a window | ||
210 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 208 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
211 | QVERIFY(clientAddedSpy.isValid()); | 209 | QVERIFY(clientAddedSpy.isValid()); | ||
212 | Surface *surface = Test::createSurface(m_compositor); | 210 | Surface *surface = Test::createSurface(m_compositor); | ||
213 | QVERIFY(surface); | 211 | QVERIFY(surface); | ||
214 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 212 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
215 | QVERIFY(shellSurface); | 213 | QVERIFY(shellSurface); | ||
216 | render(surface); | 214 | render(surface); | ||
217 | QVERIFY(clientAddedSpy.wait()); | 215 | QVERIFY(clientAddedSpy.wait()); | ||
218 | AbstractClient *window = workspace()->activeClient(); | 216 | AbstractClient *window = workspace()->activeClient(); | ||
219 | QVERIFY(window); | 217 | QVERIFY(window); | ||
220 | 218 | | |||
221 | // currently there should not be a focused pointer surface | 219 | // currently there should not be a focused pointer surface | ||
222 | QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); | 220 | QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); | ||
Show All 31 Lines | 243 | { | |||
254 | QSignalSpy movedSpy(pointer, &Pointer::motion); | 252 | QSignalSpy movedSpy(pointer, &Pointer::motion); | ||
255 | QVERIFY(movedSpy.isValid()); | 253 | QVERIFY(movedSpy.isValid()); | ||
256 | 254 | | |||
257 | // create a window | 255 | // create a window | ||
258 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 256 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
259 | QVERIFY(clientAddedSpy.isValid()); | 257 | QVERIFY(clientAddedSpy.isValid()); | ||
260 | Surface *surface = Test::createSurface(m_compositor); | 258 | Surface *surface = Test::createSurface(m_compositor); | ||
261 | QVERIFY(surface); | 259 | QVERIFY(surface); | ||
262 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 260 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
263 | QVERIFY(shellSurface); | 261 | QVERIFY(shellSurface); | ||
264 | render(surface); | 262 | render(surface); | ||
265 | QVERIFY(clientAddedSpy.wait()); | 263 | QVERIFY(clientAddedSpy.wait()); | ||
266 | AbstractClient *window = workspace()->activeClient(); | 264 | AbstractClient *window = workspace()->activeClient(); | ||
267 | QVERIFY(window); | 265 | QVERIFY(window); | ||
268 | 266 | | |||
269 | // enter | 267 | // enter | ||
270 | kwinApp()->platform()->pointerMotion(QPointF(25, 25), 1); | 268 | kwinApp()->platform()->pointerMotion(QPointF(25, 25), 1); | ||
Show All 23 Lines | 280 | { | |||
294 | // warp cursor into expected geometry | 292 | // warp cursor into expected geometry | ||
295 | Cursor::setPos(10, 10); | 293 | Cursor::setPos(10, 10); | ||
296 | 294 | | |||
297 | // create a window | 295 | // create a window | ||
298 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 296 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
299 | QVERIFY(clientAddedSpy.isValid()); | 297 | QVERIFY(clientAddedSpy.isValid()); | ||
300 | Surface *surface = Test::createSurface(m_compositor); | 298 | Surface *surface = Test::createSurface(m_compositor); | ||
301 | QVERIFY(surface); | 299 | QVERIFY(surface); | ||
302 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 300 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
303 | QVERIFY(shellSurface); | 301 | QVERIFY(shellSurface); | ||
304 | render(surface); | 302 | render(surface); | ||
305 | QVERIFY(clientAddedSpy.wait()); | 303 | QVERIFY(clientAddedSpy.wait()); | ||
306 | AbstractClient *window = workspace()->activeClient(); | 304 | AbstractClient *window = workspace()->activeClient(); | ||
307 | QVERIFY(window); | 305 | QVERIFY(window); | ||
308 | 306 | | |||
309 | QCOMPARE(window->pos(), QPoint(0, 0)); | 307 | QCOMPARE(window->pos(), QPoint(0, 0)); | ||
310 | QVERIFY(window->geometry().contains(Cursor::pos())); | 308 | QVERIFY(window->geometry().contains(Cursor::pos())); | ||
Show All 26 Lines | 324 | { | |||
337 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | 335 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||
338 | QVERIFY(enteredSpy.isValid()); | 336 | QVERIFY(enteredSpy.isValid()); | ||
339 | 337 | | |||
340 | // create a window | 338 | // create a window | ||
341 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 339 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
342 | QVERIFY(clientAddedSpy.isValid()); | 340 | QVERIFY(clientAddedSpy.isValid()); | ||
343 | Surface *surface = Test::createSurface(m_compositor); | 341 | Surface *surface = Test::createSurface(m_compositor); | ||
344 | QVERIFY(surface); | 342 | QVERIFY(surface); | ||
345 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 343 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
346 | QVERIFY(shellSurface); | 344 | QVERIFY(shellSurface); | ||
347 | render(surface, QSize(1280, 1024)); | 345 | render(surface, QSize(1280, 1024)); | ||
348 | QVERIFY(clientAddedSpy.wait()); | 346 | QVERIFY(clientAddedSpy.wait()); | ||
349 | AbstractClient *window = workspace()->activeClient(); | 347 | AbstractClient *window = workspace()->activeClient(); | ||
350 | QVERIFY(window); | 348 | QVERIFY(window); | ||
351 | QVERIFY(!window->geometry().contains(Cursor::pos())); | 349 | QVERIFY(!window->geometry().contains(Cursor::pos())); | ||
352 | 350 | | |||
353 | QSignalSpy screensChangedSpy(screens(), &Screens::changed); | 351 | QSignalSpy screensChangedSpy(screens(), &Screens::changed); | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 410 | { | |||
433 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | 431 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||
434 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | 432 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||
435 | 433 | | |||
436 | // create a window | 434 | // create a window | ||
437 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 435 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
438 | QVERIFY(clientAddedSpy.isValid()); | 436 | QVERIFY(clientAddedSpy.isValid()); | ||
439 | Surface *surface = Test::createSurface(m_compositor); | 437 | Surface *surface = Test::createSurface(m_compositor); | ||
440 | QVERIFY(surface); | 438 | QVERIFY(surface); | ||
441 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 439 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
442 | QVERIFY(shellSurface); | 440 | QVERIFY(shellSurface); | ||
443 | render(surface); | 441 | render(surface); | ||
444 | QVERIFY(clientAddedSpy.wait()); | 442 | QVERIFY(clientAddedSpy.wait()); | ||
445 | AbstractClient *window = workspace()->activeClient(); | 443 | AbstractClient *window = workspace()->activeClient(); | ||
446 | QVERIFY(window); | 444 | QVERIFY(window); | ||
447 | 445 | | |||
448 | // move cursor on window | 446 | // move cursor on window | ||
449 | Cursor::setPos(window->geometry().center()); | 447 | Cursor::setPos(window->geometry().center()); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 478 | { | |||
500 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | 498 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||
501 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | 499 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||
502 | 500 | | |||
503 | // create a window | 501 | // create a window | ||
504 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 502 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
505 | QVERIFY(clientAddedSpy.isValid()); | 503 | QVERIFY(clientAddedSpy.isValid()); | ||
506 | Surface *surface = Test::createSurface(m_compositor); | 504 | Surface *surface = Test::createSurface(m_compositor); | ||
507 | QVERIFY(surface); | 505 | QVERIFY(surface); | ||
508 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 506 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
509 | QVERIFY(shellSurface); | 507 | QVERIFY(shellSurface); | ||
510 | render(surface); | 508 | render(surface); | ||
511 | QVERIFY(clientAddedSpy.wait()); | 509 | QVERIFY(clientAddedSpy.wait()); | ||
512 | AbstractClient *window = workspace()->activeClient(); | 510 | AbstractClient *window = workspace()->activeClient(); | ||
513 | QVERIFY(window); | 511 | QVERIFY(window); | ||
514 | 512 | | |||
515 | // disable global shortcuts | 513 | // disable global shortcuts | ||
516 | QVERIFY(!workspace()->globalShortcutsDisabled()); | 514 | QVERIFY(!workspace()->globalShortcutsDisabled()); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 555 | { | |||
573 | group.sync(); | 571 | group.sync(); | ||
574 | workspace()->slotReconfigure(); | 572 | workspace()->slotReconfigure(); | ||
575 | 573 | | |||
576 | // create a window | 574 | // create a window | ||
577 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 575 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
578 | QVERIFY(clientAddedSpy.isValid()); | 576 | QVERIFY(clientAddedSpy.isValid()); | ||
579 | Surface *surface = Test::createSurface(m_compositor); | 577 | Surface *surface = Test::createSurface(m_compositor); | ||
580 | QVERIFY(surface); | 578 | QVERIFY(surface); | ||
581 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 579 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
582 | QVERIFY(shellSurface); | 580 | QVERIFY(shellSurface); | ||
583 | render(surface); | 581 | render(surface); | ||
584 | QVERIFY(clientAddedSpy.wait()); | 582 | QVERIFY(clientAddedSpy.wait()); | ||
585 | AbstractClient *window = workspace()->activeClient(); | 583 | AbstractClient *window = workspace()->activeClient(); | ||
586 | QVERIFY(window); | 584 | QVERIFY(window); | ||
587 | // set the opacity to 0.5 | 585 | // set the opacity to 0.5 | ||
588 | window->setOpacity(0.5); | 586 | window->setOpacity(0.5); | ||
589 | QCOMPARE(window->opacity(), 0.5); | 587 | QCOMPARE(window->opacity(), 0.5); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 615 | { | |||
632 | group.sync(); | 630 | group.sync(); | ||
633 | workspace()->slotReconfigure(); | 631 | workspace()->slotReconfigure(); | ||
634 | 632 | | |||
635 | // create a window | 633 | // create a window | ||
636 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 634 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
637 | QVERIFY(clientAddedSpy.isValid()); | 635 | QVERIFY(clientAddedSpy.isValid()); | ||
638 | Surface *surface = Test::createSurface(m_compositor); | 636 | Surface *surface = Test::createSurface(m_compositor); | ||
639 | QVERIFY(surface); | 637 | QVERIFY(surface); | ||
640 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 638 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
641 | QVERIFY(shellSurface); | 639 | QVERIFY(shellSurface); | ||
642 | render(surface); | 640 | render(surface); | ||
643 | QVERIFY(clientAddedSpy.wait()); | 641 | QVERIFY(clientAddedSpy.wait()); | ||
644 | AbstractClient *window = workspace()->activeClient(); | 642 | AbstractClient *window = workspace()->activeClient(); | ||
645 | QVERIFY(window); | 643 | QVERIFY(window); | ||
646 | // set the opacity to 0.5 | 644 | // set the opacity to 0.5 | ||
647 | window->setOpacity(0.5); | 645 | window->setOpacity(0.5); | ||
648 | QCOMPARE(window->opacity(), 0.5); | 646 | QCOMPARE(window->opacity(), 0.5); | ||
Show All 33 Lines | 669 | { | |||
682 | group.writeEntry("CommandWindowWheel", "activate and scroll"); | 680 | group.writeEntry("CommandWindowWheel", "activate and scroll"); | ||
683 | group.sync(); | 681 | group.sync(); | ||
684 | workspace()->slotReconfigure(); | 682 | workspace()->slotReconfigure(); | ||
685 | // create two windows | 683 | // create two windows | ||
686 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 684 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
687 | QVERIFY(clientAddedSpy.isValid()); | 685 | QVERIFY(clientAddedSpy.isValid()); | ||
688 | Surface *surface1 = Test::createSurface(m_compositor); | 686 | Surface *surface1 = Test::createSurface(m_compositor); | ||
689 | QVERIFY(surface1); | 687 | QVERIFY(surface1); | ||
690 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 688 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
691 | QVERIFY(shellSurface1); | 689 | QVERIFY(shellSurface1); | ||
692 | render(surface1); | 690 | render(surface1); | ||
693 | QVERIFY(clientAddedSpy.wait()); | 691 | QVERIFY(clientAddedSpy.wait()); | ||
694 | AbstractClient *window1 = workspace()->activeClient(); | 692 | AbstractClient *window1 = workspace()->activeClient(); | ||
695 | QVERIFY(window1); | 693 | QVERIFY(window1); | ||
696 | Surface *surface2 = Test::createSurface(m_compositor); | 694 | Surface *surface2 = Test::createSurface(m_compositor); | ||
697 | QVERIFY(surface2); | 695 | QVERIFY(surface2); | ||
698 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 696 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
699 | QVERIFY(shellSurface2); | 697 | QVERIFY(shellSurface2); | ||
700 | render(surface2); | 698 | render(surface2); | ||
701 | QVERIFY(clientAddedSpy.wait()); | 699 | QVERIFY(clientAddedSpy.wait()); | ||
702 | AbstractClient *window2 = workspace()->activeClient(); | 700 | AbstractClient *window2 = workspace()->activeClient(); | ||
703 | QVERIFY(window2); | 701 | QVERIFY(window2); | ||
704 | QVERIFY(window1 != window2); | 702 | QVERIFY(window1 != window2); | ||
705 | 703 | | |||
706 | // move cursor to the inactive window | 704 | // move cursor to the inactive window | ||
Show All 35 Lines | 720 | { | |||
742 | QCOMPARE(options->autoRaiseInterval(), 20); | 740 | QCOMPARE(options->autoRaiseInterval(), 20); | ||
743 | QCOMPARE(options->delayFocusInterval(), 200); | 741 | QCOMPARE(options->delayFocusInterval(), 200); | ||
744 | 742 | | |||
745 | // create two windows | 743 | // create two windows | ||
746 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 744 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
747 | QVERIFY(clientAddedSpy.isValid()); | 745 | QVERIFY(clientAddedSpy.isValid()); | ||
748 | Surface *surface1 = Test::createSurface(m_compositor); | 746 | Surface *surface1 = Test::createSurface(m_compositor); | ||
749 | QVERIFY(surface1); | 747 | QVERIFY(surface1); | ||
750 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 748 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
751 | QVERIFY(shellSurface1); | 749 | QVERIFY(shellSurface1); | ||
752 | render(surface1, QSize(800, 800)); | 750 | render(surface1, QSize(800, 800)); | ||
753 | QVERIFY(clientAddedSpy.wait()); | 751 | QVERIFY(clientAddedSpy.wait()); | ||
754 | AbstractClient *window1 = workspace()->activeClient(); | 752 | AbstractClient *window1 = workspace()->activeClient(); | ||
755 | QVERIFY(window1); | 753 | QVERIFY(window1); | ||
756 | Surface *surface2 = Test::createSurface(m_compositor); | 754 | Surface *surface2 = Test::createSurface(m_compositor); | ||
757 | QVERIFY(surface2); | 755 | QVERIFY(surface2); | ||
758 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 756 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
759 | QVERIFY(shellSurface2); | 757 | QVERIFY(shellSurface2); | ||
760 | render(surface2, QSize(800, 800)); | 758 | render(surface2, QSize(800, 800)); | ||
761 | QVERIFY(clientAddedSpy.wait()); | 759 | QVERIFY(clientAddedSpy.wait()); | ||
762 | AbstractClient *window2 = workspace()->activeClient(); | 760 | AbstractClient *window2 = workspace()->activeClient(); | ||
763 | QVERIFY(window2); | 761 | QVERIFY(window2); | ||
764 | QVERIFY(window1 != window2); | 762 | QVERIFY(window1 != window2); | ||
765 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | 763 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | ||
766 | // geometry of the two windows should be overlapping | 764 | // geometry of the two windows should be overlapping | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 813 | { | |||
828 | group.sync(); | 826 | group.sync(); | ||
829 | workspace()->slotReconfigure(); | 827 | workspace()->slotReconfigure(); | ||
830 | 828 | | |||
831 | // create two windows | 829 | // create two windows | ||
832 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 830 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
833 | QVERIFY(clientAddedSpy.isValid()); | 831 | QVERIFY(clientAddedSpy.isValid()); | ||
834 | Surface *surface1 = Test::createSurface(m_compositor); | 832 | Surface *surface1 = Test::createSurface(m_compositor); | ||
835 | QVERIFY(surface1); | 833 | QVERIFY(surface1); | ||
836 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 834 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
837 | QVERIFY(shellSurface1); | 835 | QVERIFY(shellSurface1); | ||
838 | render(surface1, QSize(800, 800)); | 836 | render(surface1, QSize(800, 800)); | ||
839 | QVERIFY(clientAddedSpy.wait()); | 837 | QVERIFY(clientAddedSpy.wait()); | ||
840 | AbstractClient *window1 = workspace()->activeClient(); | 838 | AbstractClient *window1 = workspace()->activeClient(); | ||
841 | QVERIFY(window1); | 839 | QVERIFY(window1); | ||
842 | Surface *surface2 = Test::createSurface(m_compositor); | 840 | Surface *surface2 = Test::createSurface(m_compositor); | ||
843 | QVERIFY(surface2); | 841 | QVERIFY(surface2); | ||
844 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 842 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
845 | QVERIFY(shellSurface2); | 843 | QVERIFY(shellSurface2); | ||
846 | render(surface2, QSize(800, 800)); | 844 | render(surface2, QSize(800, 800)); | ||
847 | QVERIFY(clientAddedSpy.wait()); | 845 | QVERIFY(clientAddedSpy.wait()); | ||
848 | AbstractClient *window2 = workspace()->activeClient(); | 846 | AbstractClient *window2 = workspace()->activeClient(); | ||
849 | QVERIFY(window2); | 847 | QVERIFY(window2); | ||
850 | QVERIFY(window1 != window2); | 848 | QVERIFY(window1 != window2); | ||
851 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | 849 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | ||
852 | // geometry of the two windows should be overlapping | 850 | // geometry of the two windows should be overlapping | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 899 | { | |||
918 | workspace()->slotReconfigure(); | 916 | workspace()->slotReconfigure(); | ||
919 | QCOMPARE(options->isClickRaise(), clickRaise); | 917 | QCOMPARE(options->isClickRaise(), clickRaise); | ||
920 | 918 | | |||
921 | // create two windows | 919 | // create two windows | ||
922 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 920 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
923 | QVERIFY(clientAddedSpy.isValid()); | 921 | QVERIFY(clientAddedSpy.isValid()); | ||
924 | Surface *surface1 = Test::createSurface(m_compositor); | 922 | Surface *surface1 = Test::createSurface(m_compositor); | ||
925 | QVERIFY(surface1); | 923 | QVERIFY(surface1); | ||
926 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 924 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
927 | QVERIFY(shellSurface1); | 925 | QVERIFY(shellSurface1); | ||
928 | render(surface1, QSize(800, 800)); | 926 | render(surface1, QSize(800, 800)); | ||
929 | QVERIFY(clientAddedSpy.wait()); | 927 | QVERIFY(clientAddedSpy.wait()); | ||
930 | AbstractClient *window1 = workspace()->activeClient(); | 928 | AbstractClient *window1 = workspace()->activeClient(); | ||
931 | QVERIFY(window1); | 929 | QVERIFY(window1); | ||
932 | QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); | 930 | QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); | ||
933 | QVERIFY(window1DestroyedSpy.isValid()); | 931 | QVERIFY(window1DestroyedSpy.isValid()); | ||
934 | Surface *surface2 = Test::createSurface(m_compositor); | 932 | Surface *surface2 = Test::createSurface(m_compositor); | ||
935 | QVERIFY(surface2); | 933 | QVERIFY(surface2); | ||
936 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 934 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
937 | QVERIFY(shellSurface2); | 935 | QVERIFY(shellSurface2); | ||
938 | render(surface2, QSize(800, 800)); | 936 | render(surface2, QSize(800, 800)); | ||
939 | QVERIFY(clientAddedSpy.wait()); | 937 | QVERIFY(clientAddedSpy.wait()); | ||
940 | AbstractClient *window2 = workspace()->activeClient(); | 938 | AbstractClient *window2 = workspace()->activeClient(); | ||
941 | QVERIFY(window2); | 939 | QVERIFY(window2); | ||
942 | QVERIFY(window1 != window2); | 940 | QVERIFY(window1 != window2); | ||
943 | QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); | 941 | QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); | ||
944 | QVERIFY(window2DestroyedSpy.isValid()); | 942 | QVERIFY(window2DestroyedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 983 | { | |||
999 | const QImage fallbackCursor = p->cursorImage(); | 997 | const QImage fallbackCursor = p->cursorImage(); | ||
1000 | QVERIFY(!fallbackCursor.isNull()); | 998 | QVERIFY(!fallbackCursor.isNull()); | ||
1001 | 999 | | |||
1002 | // create a window | 1000 | // create a window | ||
1003 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1001 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1004 | QVERIFY(clientAddedSpy.isValid()); | 1002 | QVERIFY(clientAddedSpy.isValid()); | ||
1005 | Surface *surface = Test::createSurface(m_compositor); | 1003 | Surface *surface = Test::createSurface(m_compositor); | ||
1006 | QVERIFY(surface); | 1004 | QVERIFY(surface); | ||
1007 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1005 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1008 | QVERIFY(shellSurface); | 1006 | QVERIFY(shellSurface); | ||
1009 | render(surface); | 1007 | render(surface); | ||
1010 | QVERIFY(clientAddedSpy.wait()); | 1008 | QVERIFY(clientAddedSpy.wait()); | ||
1011 | AbstractClient *window = workspace()->activeClient(); | 1009 | AbstractClient *window = workspace()->activeClient(); | ||
1012 | QVERIFY(window); | 1010 | QVERIFY(window); | ||
1013 | 1011 | | |||
1014 | // move cursor to center of window, this should first set a null pointer, so we still show old cursor | 1012 | // move cursor to center of window, this should first set a null pointer, so we still show old cursor | ||
1015 | Cursor::setPos(window->geometry().center()); | 1013 | Cursor::setPos(window->geometry().center()); | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 1083 | { | |||
1100 | const QImage fallback = p->cursorImage(); | 1098 | const QImage fallback = p->cursorImage(); | ||
1101 | QVERIFY(!fallback.isNull()); | 1099 | QVERIFY(!fallback.isNull()); | ||
1102 | 1100 | | |||
1103 | // now let's create a window | 1101 | // now let's create a window | ||
1104 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1102 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1105 | QVERIFY(clientAddedSpy.isValid()); | 1103 | QVERIFY(clientAddedSpy.isValid()); | ||
1106 | Surface *surface = Test::createSurface(m_compositor); | 1104 | Surface *surface = Test::createSurface(m_compositor); | ||
1107 | QVERIFY(surface); | 1105 | QVERIFY(surface); | ||
1108 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1106 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1109 | QVERIFY(shellSurface); | 1107 | QVERIFY(shellSurface); | ||
1110 | render(surface); | 1108 | render(surface); | ||
1111 | QVERIFY(clientAddedSpy.wait()); | 1109 | QVERIFY(clientAddedSpy.wait()); | ||
1112 | AbstractClient *window = workspace()->activeClient(); | 1110 | AbstractClient *window = workspace()->activeClient(); | ||
1113 | QVERIFY(window); | 1111 | QVERIFY(window); | ||
1114 | 1112 | | |||
1115 | // and move cursor to the window | 1113 | // and move cursor to the window | ||
1116 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 1114 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 1158 | { | |||
1176 | QVERIFY(motionSpy.isValid()); | 1174 | QVERIFY(motionSpy.isValid()); | ||
1177 | 1175 | | |||
1178 | Cursor::setPos(800, 800); | 1176 | Cursor::setPos(800, 800); | ||
1179 | 1177 | | |||
1180 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1178 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1181 | QVERIFY(clientAddedSpy.isValid()); | 1179 | QVERIFY(clientAddedSpy.isValid()); | ||
1182 | Surface *surface = Test::createSurface(m_compositor); | 1180 | Surface *surface = Test::createSurface(m_compositor); | ||
1183 | QVERIFY(surface); | 1181 | QVERIFY(surface); | ||
1184 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1182 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1185 | QVERIFY(shellSurface); | 1183 | QVERIFY(shellSurface); | ||
1186 | render(surface); | 1184 | render(surface); | ||
1187 | QVERIFY(clientAddedSpy.wait()); | 1185 | QVERIFY(clientAddedSpy.wait()); | ||
1188 | AbstractClient *window = workspace()->activeClient(); | 1186 | AbstractClient *window = workspace()->activeClient(); | ||
1189 | QVERIFY(window); | 1187 | QVERIFY(window); | ||
1190 | QCOMPARE(window->hasPopupGrab(), false); | 1188 | QCOMPARE(window->hasPopupGrab(), false); | ||
1191 | // move pointer into window | 1189 | // move pointer into window | ||
1192 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 1190 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
1193 | Cursor::setPos(window->geometry().center()); | 1191 | Cursor::setPos(window->geometry().center()); | ||
1194 | QVERIFY(enteredSpy.wait()); | 1192 | QVERIFY(enteredSpy.wait()); | ||
1195 | // click inside window to create serial | 1193 | // click inside window to create serial | ||
1196 | quint32 timestamp = 0; | 1194 | quint32 timestamp = 0; | ||
1197 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 1195 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
1198 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1196 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1199 | QVERIFY(buttonStateChangedSpy.wait()); | 1197 | QVERIFY(buttonStateChangedSpy.wait()); | ||
1200 | 1198 | | |||
1201 | // now create the popup surface | 1199 | // now create the popup surface | ||
1200 | XdgPositioner positioner(QSize(100, 50), QRect(0, 0, 80, 20)); | ||||
1201 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
1202 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
1202 | Surface *popupSurface = Test::createSurface(m_compositor); | 1203 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1203 | QVERIFY(popupSurface); | 1204 | QVERIFY(popupSurface); | ||
1204 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | 1205 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1205 | QVERIFY(popupShellSurface); | 1206 | QVERIFY(popupShellSurface); | ||
1206 | QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); | 1207 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1207 | QVERIFY(popupDoneSpy.isValid()); | 1208 | QVERIFY(popupDoneSpy.isValid()); | ||
1208 | // TODO: proper serial | 1209 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1209 | popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); | 1210 | render(popupSurface, positioner.initialSize()); | ||
1210 | render(popupSurface); | | |||
1211 | QVERIFY(clientAddedSpy.wait()); | 1211 | QVERIFY(clientAddedSpy.wait()); | ||
1212 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1212 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||
1213 | QVERIFY(popupClient); | 1213 | QVERIFY(popupClient); | ||
1214 | QVERIFY(popupClient != window); | 1214 | QVERIFY(popupClient != window); | ||
1215 | QCOMPARE(window, workspace()->activeClient()); | 1215 | QCOMPARE(window, workspace()->activeClient()); | ||
1216 | QCOMPARE(popupClient->transientFor(), window); | 1216 | QCOMPARE(popupClient->transientFor(), window); | ||
1217 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | 1217 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | ||
1218 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1218 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
Show All 36 Lines | 1240 | { | |||
1255 | QSignalSpy motionSpy(pointer, &Pointer::motion); | 1255 | QSignalSpy motionSpy(pointer, &Pointer::motion); | ||
1256 | QVERIFY(motionSpy.isValid()); | 1256 | QVERIFY(motionSpy.isValid()); | ||
1257 | 1257 | | |||
1258 | Cursor::setPos(800, 800); | 1258 | Cursor::setPos(800, 800); | ||
1259 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1259 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1260 | QVERIFY(clientAddedSpy.isValid()); | 1260 | QVERIFY(clientAddedSpy.isValid()); | ||
1261 | Surface *surface = Test::createSurface(m_compositor); | 1261 | Surface *surface = Test::createSurface(m_compositor); | ||
1262 | QVERIFY(surface); | 1262 | QVERIFY(surface); | ||
1263 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1263 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1264 | QVERIFY(shellSurface); | 1264 | QVERIFY(shellSurface); | ||
1265 | 1265 | | |||
1266 | auto deco = Test::waylandServerSideDecoration()->create(surface, surface); | 1266 | auto deco = Test::waylandServerSideDecoration()->create(surface, surface); | ||
1267 | QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged); | 1267 | QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged); | ||
1268 | QVERIFY(decoSpy.isValid()); | 1268 | QVERIFY(decoSpy.isValid()); | ||
1269 | QVERIFY(decoSpy.wait()); | 1269 | QVERIFY(decoSpy.wait()); | ||
1270 | deco->requestMode(ServerSideDecoration::Mode::Server); | 1270 | deco->requestMode(ServerSideDecoration::Mode::Server); | ||
1271 | QVERIFY(decoSpy.wait()); | 1271 | QVERIFY(decoSpy.wait()); | ||
Show All 11 Lines | |||||
1283 | QVERIFY(enteredSpy.wait()); | 1283 | QVERIFY(enteredSpy.wait()); | ||
1284 | // click inside window to create serial | 1284 | // click inside window to create serial | ||
1285 | quint32 timestamp = 0; | 1285 | quint32 timestamp = 0; | ||
1286 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 1286 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
1287 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1287 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1288 | QVERIFY(buttonStateChangedSpy.wait()); | 1288 | QVERIFY(buttonStateChangedSpy.wait()); | ||
1289 | 1289 | | |||
1290 | // now create the popup surface | 1290 | // now create the popup surface | ||
1291 | XdgPositioner positioner(QSize(100, 50), QRect(0, 0, 80, 20)); | ||||
1292 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
1293 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
1291 | Surface *popupSurface = Test::createSurface(m_compositor); | 1294 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1292 | QVERIFY(popupSurface); | 1295 | QVERIFY(popupSurface); | ||
1293 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | 1296 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1294 | QVERIFY(popupShellSurface); | 1297 | QVERIFY(popupShellSurface); | ||
1295 | QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); | 1298 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1296 | QVERIFY(popupDoneSpy.isValid()); | 1299 | QVERIFY(popupDoneSpy.isValid()); | ||
1297 | // TODO: proper serial | 1300 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1298 | popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); | 1301 | render(popupSurface, positioner.initialSize()); | ||
1299 | render(popupSurface); | | |||
1300 | QVERIFY(clientAddedSpy.wait()); | 1302 | QVERIFY(clientAddedSpy.wait()); | ||
1301 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1303 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||
1302 | QVERIFY(popupClient); | 1304 | QVERIFY(popupClient); | ||
1303 | QVERIFY(popupClient != window); | 1305 | QVERIFY(popupClient != window); | ||
1304 | QCOMPARE(window, workspace()->activeClient()); | 1306 | QCOMPARE(window, workspace()->activeClient()); | ||
1305 | QCOMPARE(popupClient->transientFor(), window); | 1307 | QCOMPARE(popupClient->transientFor(), window); | ||
1306 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | 1308 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | ||
1307 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1309 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
Show All 22 Lines | 1320 | { | |||
1330 | QSignalSpy leftSpy(pointer, &Pointer::left); | 1332 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||
1331 | QVERIFY(leftSpy.isValid()); | 1333 | QVERIFY(leftSpy.isValid()); | ||
1332 | 1334 | | |||
1333 | Cursor::setPos(800, 800); | 1335 | Cursor::setPos(800, 800); | ||
1334 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1336 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1335 | QVERIFY(clientAddedSpy.isValid()); | 1337 | QVERIFY(clientAddedSpy.isValid()); | ||
1336 | Surface *surface = Test::createSurface(m_compositor); | 1338 | Surface *surface = Test::createSurface(m_compositor); | ||
1337 | QVERIFY(surface); | 1339 | QVERIFY(surface); | ||
1338 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1340 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1339 | QVERIFY(shellSurface); | 1341 | QVERIFY(shellSurface); | ||
1340 | render(surface); | 1342 | render(surface); | ||
1341 | QVERIFY(clientAddedSpy.wait()); | 1343 | QVERIFY(clientAddedSpy.wait()); | ||
1342 | AbstractClient *window = workspace()->activeClient(); | 1344 | AbstractClient *window = workspace()->activeClient(); | ||
1343 | QVERIFY(window); | 1345 | QVERIFY(window); | ||
1344 | 1346 | | |||
1345 | // move cursor over window | 1347 | // move cursor over window | ||
1346 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 1348 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
1347 | Cursor::setPos(window->geometry().center()); | 1349 | Cursor::setPos(window->geometry().center()); | ||
1348 | QVERIFY(enteredSpy.wait()); | 1350 | QVERIFY(enteredSpy.wait()); | ||
1349 | // click inside window | 1351 | // click inside window | ||
1350 | quint32 timestamp = 0; | 1352 | quint32 timestamp = 0; | ||
1351 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 1353 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
1352 | 1354 | | |||
1353 | // now create a second window as transient | 1355 | // now create a second window as transient | ||
1356 | XdgPositioner positioner(QSize(99, 49), QRect(0, 0, 1, 1)); | ||||
1357 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
1358 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
1354 | Surface *popupSurface = Test::createSurface(m_compositor); | 1359 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1355 | QVERIFY(popupSurface); | 1360 | QVERIFY(popupSurface); | ||
1356 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | 1361 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1357 | QVERIFY(popupShellSurface); | 1362 | QVERIFY(popupShellSurface); | ||
1358 | popupShellSurface->setTransient(surface, QPoint(0, 0)); | 1363 | render(popupSurface, positioner.initialSize()); | ||
1359 | render(popupSurface); | | |||
1360 | QVERIFY(clientAddedSpy.wait()); | 1364 | QVERIFY(clientAddedSpy.wait()); | ||
1361 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1365 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||
1362 | QVERIFY(popupClient); | 1366 | QVERIFY(popupClient); | ||
1363 | QVERIFY(popupClient != window); | 1367 | QVERIFY(popupClient != window); | ||
1364 | QCOMPARE(window->geometry(), popupClient->geometry()); | 1368 | QVERIFY(window->geometry().contains(Cursor::pos())); | ||
1369 | QVERIFY(popupClient->geometry().contains(Cursor::pos())); | ||||
1365 | QVERIFY(!leftSpy.wait()); | 1370 | QVERIFY(!leftSpy.wait()); | ||
1366 | 1371 | | |||
1367 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1372 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1368 | // now that the button is no longer pressed we should get the leave event | 1373 | // now that the button is no longer pressed we should get the leave event | ||
1369 | QVERIFY(leftSpy.wait()); | 1374 | QVERIFY(leftSpy.wait()); | ||
1370 | QCOMPARE(leftSpy.count(), 1); | 1375 | QCOMPARE(leftSpy.count(), 1); | ||
1371 | QCOMPARE(enteredSpy.count(), 2); | 1376 | QCOMPARE(enteredSpy.count(), 2); | ||
1372 | } | 1377 | } | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 1556 | { | |||
1592 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | 1597 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||
1593 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1598 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1594 | QVERIFY(!c->isMove()); | 1599 | QVERIFY(!c->isMove()); | ||
1595 | 1600 | | |||
1596 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | 1601 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | ||
1597 | QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); | 1602 | QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); | ||
1598 | } | 1603 | } | ||
1599 | 1604 | | |||
1605 | void PointerInputTest::testHideShowCursor() | ||||
1606 | { | ||||
1607 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), false); | ||||
1608 | kwinApp()->platform()->hideCursor(); | ||||
1609 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1610 | kwinApp()->platform()->showCursor(); | ||||
1611 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), false); | ||||
1612 | | ||||
1613 | kwinApp()->platform()->hideCursor(); | ||||
1614 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1615 | kwinApp()->platform()->hideCursor(); | ||||
1616 | kwinApp()->platform()->hideCursor(); | ||||
1617 | kwinApp()->platform()->hideCursor(); | ||||
1618 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1619 | | ||||
1620 | kwinApp()->platform()->showCursor(); | ||||
1621 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1622 | kwinApp()->platform()->showCursor(); | ||||
1623 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1624 | kwinApp()->platform()->showCursor(); | ||||
1625 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1626 | kwinApp()->platform()->showCursor(); | ||||
1627 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), false); | ||||
1628 | } | ||||
1629 | | ||||
1600 | } | 1630 | } | ||
1601 | 1631 | | |||
1602 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | 1632 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | ||
1603 | #include "pointer_input.moc" | 1633 | #include "pointer_input.moc" |