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 80 Lines • ▼ Show 20 Line(s) | 411 | { | |||
434 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | 432 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||
435 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | 433 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||
436 | 434 | | |||
437 | // create a window | 435 | // create a window | ||
438 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 436 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
439 | QVERIFY(clientAddedSpy.isValid()); | 437 | QVERIFY(clientAddedSpy.isValid()); | ||
440 | Surface *surface = Test::createSurface(m_compositor); | 438 | Surface *surface = Test::createSurface(m_compositor); | ||
441 | QVERIFY(surface); | 439 | QVERIFY(surface); | ||
442 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 440 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
443 | QVERIFY(shellSurface); | 441 | QVERIFY(shellSurface); | ||
444 | render(surface); | 442 | render(surface); | ||
445 | QVERIFY(clientAddedSpy.wait()); | 443 | QVERIFY(clientAddedSpy.wait()); | ||
446 | AbstractClient *window = workspace()->activeClient(); | 444 | AbstractClient *window = workspace()->activeClient(); | ||
447 | QVERIFY(window); | 445 | QVERIFY(window); | ||
448 | 446 | | |||
449 | // move cursor on window | 447 | // move cursor on window | ||
450 | Cursor::setPos(window->geometry().center()); | 448 | Cursor::setPos(window->geometry().center()); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 479 | { | |||
501 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | 499 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||
502 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | 500 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||
503 | 501 | | |||
504 | // create a window | 502 | // create a window | ||
505 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 503 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
506 | QVERIFY(clientAddedSpy.isValid()); | 504 | QVERIFY(clientAddedSpy.isValid()); | ||
507 | Surface *surface = Test::createSurface(m_compositor); | 505 | Surface *surface = Test::createSurface(m_compositor); | ||
508 | QVERIFY(surface); | 506 | QVERIFY(surface); | ||
509 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 507 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
510 | QVERIFY(shellSurface); | 508 | QVERIFY(shellSurface); | ||
511 | render(surface); | 509 | render(surface); | ||
512 | QVERIFY(clientAddedSpy.wait()); | 510 | QVERIFY(clientAddedSpy.wait()); | ||
513 | AbstractClient *window = workspace()->activeClient(); | 511 | AbstractClient *window = workspace()->activeClient(); | ||
514 | QVERIFY(window); | 512 | QVERIFY(window); | ||
515 | 513 | | |||
516 | // disable global shortcuts | 514 | // disable global shortcuts | ||
517 | QVERIFY(!workspace()->globalShortcutsDisabled()); | 515 | QVERIFY(!workspace()->globalShortcutsDisabled()); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 556 | { | |||
574 | group.sync(); | 572 | group.sync(); | ||
575 | workspace()->slotReconfigure(); | 573 | workspace()->slotReconfigure(); | ||
576 | 574 | | |||
577 | // create a window | 575 | // create a window | ||
578 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 576 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
579 | QVERIFY(clientAddedSpy.isValid()); | 577 | QVERIFY(clientAddedSpy.isValid()); | ||
580 | Surface *surface = Test::createSurface(m_compositor); | 578 | Surface *surface = Test::createSurface(m_compositor); | ||
581 | QVERIFY(surface); | 579 | QVERIFY(surface); | ||
582 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 580 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
583 | QVERIFY(shellSurface); | 581 | QVERIFY(shellSurface); | ||
584 | render(surface); | 582 | render(surface); | ||
585 | QVERIFY(clientAddedSpy.wait()); | 583 | QVERIFY(clientAddedSpy.wait()); | ||
586 | AbstractClient *window = workspace()->activeClient(); | 584 | AbstractClient *window = workspace()->activeClient(); | ||
587 | QVERIFY(window); | 585 | QVERIFY(window); | ||
588 | // set the opacity to 0.5 | 586 | // set the opacity to 0.5 | ||
589 | window->setOpacity(0.5); | 587 | window->setOpacity(0.5); | ||
590 | QCOMPARE(window->opacity(), 0.5); | 588 | QCOMPARE(window->opacity(), 0.5); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 616 | { | |||
633 | group.sync(); | 631 | group.sync(); | ||
634 | workspace()->slotReconfigure(); | 632 | workspace()->slotReconfigure(); | ||
635 | 633 | | |||
636 | // create a window | 634 | // create a window | ||
637 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 635 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
638 | QVERIFY(clientAddedSpy.isValid()); | 636 | QVERIFY(clientAddedSpy.isValid()); | ||
639 | Surface *surface = Test::createSurface(m_compositor); | 637 | Surface *surface = Test::createSurface(m_compositor); | ||
640 | QVERIFY(surface); | 638 | QVERIFY(surface); | ||
641 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 639 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
642 | QVERIFY(shellSurface); | 640 | QVERIFY(shellSurface); | ||
643 | render(surface); | 641 | render(surface); | ||
644 | QVERIFY(clientAddedSpy.wait()); | 642 | QVERIFY(clientAddedSpy.wait()); | ||
645 | AbstractClient *window = workspace()->activeClient(); | 643 | AbstractClient *window = workspace()->activeClient(); | ||
646 | QVERIFY(window); | 644 | QVERIFY(window); | ||
647 | // set the opacity to 0.5 | 645 | // set the opacity to 0.5 | ||
648 | window->setOpacity(0.5); | 646 | window->setOpacity(0.5); | ||
649 | QCOMPARE(window->opacity(), 0.5); | 647 | QCOMPARE(window->opacity(), 0.5); | ||
Show All 33 Lines | 670 | { | |||
683 | group.writeEntry("CommandWindowWheel", "activate and scroll"); | 681 | group.writeEntry("CommandWindowWheel", "activate and scroll"); | ||
684 | group.sync(); | 682 | group.sync(); | ||
685 | workspace()->slotReconfigure(); | 683 | workspace()->slotReconfigure(); | ||
686 | // create two windows | 684 | // create two windows | ||
687 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 685 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
688 | QVERIFY(clientAddedSpy.isValid()); | 686 | QVERIFY(clientAddedSpy.isValid()); | ||
689 | Surface *surface1 = Test::createSurface(m_compositor); | 687 | Surface *surface1 = Test::createSurface(m_compositor); | ||
690 | QVERIFY(surface1); | 688 | QVERIFY(surface1); | ||
691 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 689 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
692 | QVERIFY(shellSurface1); | 690 | QVERIFY(shellSurface1); | ||
693 | render(surface1); | 691 | render(surface1); | ||
694 | QVERIFY(clientAddedSpy.wait()); | 692 | QVERIFY(clientAddedSpy.wait()); | ||
695 | AbstractClient *window1 = workspace()->activeClient(); | 693 | AbstractClient *window1 = workspace()->activeClient(); | ||
696 | QVERIFY(window1); | 694 | QVERIFY(window1); | ||
697 | Surface *surface2 = Test::createSurface(m_compositor); | 695 | Surface *surface2 = Test::createSurface(m_compositor); | ||
698 | QVERIFY(surface2); | 696 | QVERIFY(surface2); | ||
699 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 697 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
700 | QVERIFY(shellSurface2); | 698 | QVERIFY(shellSurface2); | ||
701 | render(surface2); | 699 | render(surface2); | ||
702 | QVERIFY(clientAddedSpy.wait()); | 700 | QVERIFY(clientAddedSpy.wait()); | ||
703 | AbstractClient *window2 = workspace()->activeClient(); | 701 | AbstractClient *window2 = workspace()->activeClient(); | ||
704 | QVERIFY(window2); | 702 | QVERIFY(window2); | ||
705 | QVERIFY(window1 != window2); | 703 | QVERIFY(window1 != window2); | ||
706 | 704 | | |||
707 | // move cursor to the inactive window | 705 | // move cursor to the inactive window | ||
Show All 35 Lines | 721 | { | |||
743 | QCOMPARE(options->autoRaiseInterval(), 20); | 741 | QCOMPARE(options->autoRaiseInterval(), 20); | ||
744 | QCOMPARE(options->delayFocusInterval(), 200); | 742 | QCOMPARE(options->delayFocusInterval(), 200); | ||
745 | 743 | | |||
746 | // create two windows | 744 | // create two windows | ||
747 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 745 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
748 | QVERIFY(clientAddedSpy.isValid()); | 746 | QVERIFY(clientAddedSpy.isValid()); | ||
749 | Surface *surface1 = Test::createSurface(m_compositor); | 747 | Surface *surface1 = Test::createSurface(m_compositor); | ||
750 | QVERIFY(surface1); | 748 | QVERIFY(surface1); | ||
751 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 749 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
752 | QVERIFY(shellSurface1); | 750 | QVERIFY(shellSurface1); | ||
753 | render(surface1, QSize(800, 800)); | 751 | render(surface1, QSize(800, 800)); | ||
754 | QVERIFY(clientAddedSpy.wait()); | 752 | QVERIFY(clientAddedSpy.wait()); | ||
755 | AbstractClient *window1 = workspace()->activeClient(); | 753 | AbstractClient *window1 = workspace()->activeClient(); | ||
756 | QVERIFY(window1); | 754 | QVERIFY(window1); | ||
757 | Surface *surface2 = Test::createSurface(m_compositor); | 755 | Surface *surface2 = Test::createSurface(m_compositor); | ||
758 | QVERIFY(surface2); | 756 | QVERIFY(surface2); | ||
759 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 757 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
760 | QVERIFY(shellSurface2); | 758 | QVERIFY(shellSurface2); | ||
761 | render(surface2, QSize(800, 800)); | 759 | render(surface2, QSize(800, 800)); | ||
762 | QVERIFY(clientAddedSpy.wait()); | 760 | QVERIFY(clientAddedSpy.wait()); | ||
763 | AbstractClient *window2 = workspace()->activeClient(); | 761 | AbstractClient *window2 = workspace()->activeClient(); | ||
764 | QVERIFY(window2); | 762 | QVERIFY(window2); | ||
765 | QVERIFY(window1 != window2); | 763 | QVERIFY(window1 != window2); | ||
766 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | 764 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | ||
767 | // geometry of the two windows should be overlapping | 765 | // geometry of the two windows should be overlapping | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 814 | { | |||
829 | group.sync(); | 827 | group.sync(); | ||
830 | workspace()->slotReconfigure(); | 828 | workspace()->slotReconfigure(); | ||
831 | 829 | | |||
832 | // create two windows | 830 | // create two windows | ||
833 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 831 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
834 | QVERIFY(clientAddedSpy.isValid()); | 832 | QVERIFY(clientAddedSpy.isValid()); | ||
835 | Surface *surface1 = Test::createSurface(m_compositor); | 833 | Surface *surface1 = Test::createSurface(m_compositor); | ||
836 | QVERIFY(surface1); | 834 | QVERIFY(surface1); | ||
837 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 835 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
838 | QVERIFY(shellSurface1); | 836 | QVERIFY(shellSurface1); | ||
839 | render(surface1, QSize(800, 800)); | 837 | render(surface1, QSize(800, 800)); | ||
840 | QVERIFY(clientAddedSpy.wait()); | 838 | QVERIFY(clientAddedSpy.wait()); | ||
841 | AbstractClient *window1 = workspace()->activeClient(); | 839 | AbstractClient *window1 = workspace()->activeClient(); | ||
842 | QVERIFY(window1); | 840 | QVERIFY(window1); | ||
843 | Surface *surface2 = Test::createSurface(m_compositor); | 841 | Surface *surface2 = Test::createSurface(m_compositor); | ||
844 | QVERIFY(surface2); | 842 | QVERIFY(surface2); | ||
845 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 843 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
846 | QVERIFY(shellSurface2); | 844 | QVERIFY(shellSurface2); | ||
847 | render(surface2, QSize(800, 800)); | 845 | render(surface2, QSize(800, 800)); | ||
848 | QVERIFY(clientAddedSpy.wait()); | 846 | QVERIFY(clientAddedSpy.wait()); | ||
849 | AbstractClient *window2 = workspace()->activeClient(); | 847 | AbstractClient *window2 = workspace()->activeClient(); | ||
850 | QVERIFY(window2); | 848 | QVERIFY(window2); | ||
851 | QVERIFY(window1 != window2); | 849 | QVERIFY(window1 != window2); | ||
852 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | 850 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | ||
853 | // geometry of the two windows should be overlapping | 851 | // geometry of the two windows should be overlapping | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 900 | { | |||
919 | workspace()->slotReconfigure(); | 917 | workspace()->slotReconfigure(); | ||
920 | QCOMPARE(options->isClickRaise(), clickRaise); | 918 | QCOMPARE(options->isClickRaise(), clickRaise); | ||
921 | 919 | | |||
922 | // create two windows | 920 | // create two windows | ||
923 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 921 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
924 | QVERIFY(clientAddedSpy.isValid()); | 922 | QVERIFY(clientAddedSpy.isValid()); | ||
925 | Surface *surface1 = Test::createSurface(m_compositor); | 923 | Surface *surface1 = Test::createSurface(m_compositor); | ||
926 | QVERIFY(surface1); | 924 | QVERIFY(surface1); | ||
927 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | 925 | XdgShellSurface *shellSurface1 = Test::createXdgShellStableSurface(surface1, surface1); | ||
928 | QVERIFY(shellSurface1); | 926 | QVERIFY(shellSurface1); | ||
929 | render(surface1, QSize(800, 800)); | 927 | render(surface1, QSize(800, 800)); | ||
930 | QVERIFY(clientAddedSpy.wait()); | 928 | QVERIFY(clientAddedSpy.wait()); | ||
931 | AbstractClient *window1 = workspace()->activeClient(); | 929 | AbstractClient *window1 = workspace()->activeClient(); | ||
932 | QVERIFY(window1); | 930 | QVERIFY(window1); | ||
933 | QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); | 931 | QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); | ||
934 | QVERIFY(window1DestroyedSpy.isValid()); | 932 | QVERIFY(window1DestroyedSpy.isValid()); | ||
935 | Surface *surface2 = Test::createSurface(m_compositor); | 933 | Surface *surface2 = Test::createSurface(m_compositor); | ||
936 | QVERIFY(surface2); | 934 | QVERIFY(surface2); | ||
937 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | 935 | XdgShellSurface *shellSurface2 = Test::createXdgShellStableSurface(surface2, surface2); | ||
938 | QVERIFY(shellSurface2); | 936 | QVERIFY(shellSurface2); | ||
939 | render(surface2, QSize(800, 800)); | 937 | render(surface2, QSize(800, 800)); | ||
940 | QVERIFY(clientAddedSpy.wait()); | 938 | QVERIFY(clientAddedSpy.wait()); | ||
941 | AbstractClient *window2 = workspace()->activeClient(); | 939 | AbstractClient *window2 = workspace()->activeClient(); | ||
942 | QVERIFY(window2); | 940 | QVERIFY(window2); | ||
943 | QVERIFY(window1 != window2); | 941 | QVERIFY(window1 != window2); | ||
944 | QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); | 942 | QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); | ||
945 | QVERIFY(window2DestroyedSpy.isValid()); | 943 | QVERIFY(window2DestroyedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 984 | { | |||
1000 | const QImage fallbackCursor = p->cursorImage(); | 998 | const QImage fallbackCursor = p->cursorImage(); | ||
1001 | QVERIFY(!fallbackCursor.isNull()); | 999 | QVERIFY(!fallbackCursor.isNull()); | ||
1002 | 1000 | | |||
1003 | // create a window | 1001 | // create a window | ||
1004 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1002 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1005 | QVERIFY(clientAddedSpy.isValid()); | 1003 | QVERIFY(clientAddedSpy.isValid()); | ||
1006 | Surface *surface = Test::createSurface(m_compositor); | 1004 | Surface *surface = Test::createSurface(m_compositor); | ||
1007 | QVERIFY(surface); | 1005 | QVERIFY(surface); | ||
1008 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1006 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1009 | QVERIFY(shellSurface); | 1007 | QVERIFY(shellSurface); | ||
1010 | render(surface); | 1008 | render(surface); | ||
1011 | QVERIFY(clientAddedSpy.wait()); | 1009 | QVERIFY(clientAddedSpy.wait()); | ||
1012 | AbstractClient *window = workspace()->activeClient(); | 1010 | AbstractClient *window = workspace()->activeClient(); | ||
1013 | QVERIFY(window); | 1011 | QVERIFY(window); | ||
1014 | 1012 | | |||
1015 | // move cursor to center of window, this should first set a null pointer, so we still show old cursor | 1013 | // move cursor to center of window, this should first set a null pointer, so we still show old cursor | ||
1016 | Cursor::setPos(window->geometry().center()); | 1014 | Cursor::setPos(window->geometry().center()); | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 1084 | { | |||
1101 | const QImage fallback = p->cursorImage(); | 1099 | const QImage fallback = p->cursorImage(); | ||
1102 | QVERIFY(!fallback.isNull()); | 1100 | QVERIFY(!fallback.isNull()); | ||
1103 | 1101 | | |||
1104 | // now let's create a window | 1102 | // now let's create a window | ||
1105 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1103 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1106 | QVERIFY(clientAddedSpy.isValid()); | 1104 | QVERIFY(clientAddedSpy.isValid()); | ||
1107 | Surface *surface = Test::createSurface(m_compositor); | 1105 | Surface *surface = Test::createSurface(m_compositor); | ||
1108 | QVERIFY(surface); | 1106 | QVERIFY(surface); | ||
1109 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1107 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1110 | QVERIFY(shellSurface); | 1108 | QVERIFY(shellSurface); | ||
1111 | render(surface); | 1109 | render(surface); | ||
1112 | QVERIFY(clientAddedSpy.wait()); | 1110 | QVERIFY(clientAddedSpy.wait()); | ||
1113 | AbstractClient *window = workspace()->activeClient(); | 1111 | AbstractClient *window = workspace()->activeClient(); | ||
1114 | QVERIFY(window); | 1112 | QVERIFY(window); | ||
1115 | 1113 | | |||
1116 | // and move cursor to the window | 1114 | // and move cursor to the window | ||
1117 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 1115 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 1159 | { | |||
1177 | QVERIFY(motionSpy.isValid()); | 1175 | QVERIFY(motionSpy.isValid()); | ||
1178 | 1176 | | |||
1179 | Cursor::setPos(800, 800); | 1177 | Cursor::setPos(800, 800); | ||
1180 | 1178 | | |||
1181 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1179 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1182 | QVERIFY(clientAddedSpy.isValid()); | 1180 | QVERIFY(clientAddedSpy.isValid()); | ||
1183 | Surface *surface = Test::createSurface(m_compositor); | 1181 | Surface *surface = Test::createSurface(m_compositor); | ||
1184 | QVERIFY(surface); | 1182 | QVERIFY(surface); | ||
1185 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1183 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1186 | QVERIFY(shellSurface); | 1184 | QVERIFY(shellSurface); | ||
1187 | render(surface); | 1185 | render(surface); | ||
1188 | QVERIFY(clientAddedSpy.wait()); | 1186 | QVERIFY(clientAddedSpy.wait()); | ||
1189 | AbstractClient *window = workspace()->activeClient(); | 1187 | AbstractClient *window = workspace()->activeClient(); | ||
1190 | QVERIFY(window); | 1188 | QVERIFY(window); | ||
1191 | QCOMPARE(window->hasPopupGrab(), false); | 1189 | QCOMPARE(window->hasPopupGrab(), false); | ||
1192 | // move pointer into window | 1190 | // move pointer into window | ||
1193 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 1191 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
1194 | Cursor::setPos(window->geometry().center()); | 1192 | Cursor::setPos(window->geometry().center()); | ||
1195 | QVERIFY(enteredSpy.wait()); | 1193 | QVERIFY(enteredSpy.wait()); | ||
1196 | // click inside window to create serial | 1194 | // click inside window to create serial | ||
1197 | quint32 timestamp = 0; | 1195 | quint32 timestamp = 0; | ||
1198 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 1196 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
1199 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1197 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1200 | QVERIFY(buttonStateChangedSpy.wait()); | 1198 | QVERIFY(buttonStateChangedSpy.wait()); | ||
1201 | 1199 | | |||
1202 | // now create the popup surface | 1200 | // now create the popup surface | ||
1201 | XdgPositioner positioner(QSize(100, 50), QRect(0, 0, 80, 20)); | ||||
1202 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
1203 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
1203 | Surface *popupSurface = Test::createSurface(m_compositor); | 1204 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1204 | QVERIFY(popupSurface); | 1205 | QVERIFY(popupSurface); | ||
1205 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | 1206 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1206 | QVERIFY(popupShellSurface); | 1207 | QVERIFY(popupShellSurface); | ||
1207 | QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); | 1208 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1208 | QVERIFY(popupDoneSpy.isValid()); | 1209 | QVERIFY(popupDoneSpy.isValid()); | ||
1209 | // TODO: proper serial | 1210 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1210 | popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); | 1211 | render(popupSurface, positioner.initialSize()); | ||
1211 | render(popupSurface); | | |||
1212 | QVERIFY(clientAddedSpy.wait()); | 1212 | QVERIFY(clientAddedSpy.wait()); | ||
1213 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1213 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||
1214 | QVERIFY(popupClient); | 1214 | QVERIFY(popupClient); | ||
1215 | QVERIFY(popupClient != window); | 1215 | QVERIFY(popupClient != window); | ||
1216 | QCOMPARE(window, workspace()->activeClient()); | 1216 | QCOMPARE(window, workspace()->activeClient()); | ||
1217 | QCOMPARE(popupClient->transientFor(), window); | 1217 | QCOMPARE(popupClient->transientFor(), window); | ||
1218 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | 1218 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | ||
1219 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1219 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
Show All 36 Lines | 1241 | { | |||
1256 | QSignalSpy motionSpy(pointer, &Pointer::motion); | 1256 | QSignalSpy motionSpy(pointer, &Pointer::motion); | ||
1257 | QVERIFY(motionSpy.isValid()); | 1257 | QVERIFY(motionSpy.isValid()); | ||
1258 | 1258 | | |||
1259 | Cursor::setPos(800, 800); | 1259 | Cursor::setPos(800, 800); | ||
1260 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1260 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1261 | QVERIFY(clientAddedSpy.isValid()); | 1261 | QVERIFY(clientAddedSpy.isValid()); | ||
1262 | Surface *surface = Test::createSurface(m_compositor); | 1262 | Surface *surface = Test::createSurface(m_compositor); | ||
1263 | QVERIFY(surface); | 1263 | QVERIFY(surface); | ||
1264 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1264 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1265 | QVERIFY(shellSurface); | 1265 | QVERIFY(shellSurface); | ||
1266 | 1266 | | |||
1267 | auto deco = Test::waylandServerSideDecoration()->create(surface, surface); | 1267 | auto deco = Test::waylandServerSideDecoration()->create(surface, surface); | ||
1268 | QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged); | 1268 | QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged); | ||
1269 | QVERIFY(decoSpy.isValid()); | 1269 | QVERIFY(decoSpy.isValid()); | ||
1270 | QVERIFY(decoSpy.wait()); | 1270 | QVERIFY(decoSpy.wait()); | ||
1271 | deco->requestMode(ServerSideDecoration::Mode::Server); | 1271 | deco->requestMode(ServerSideDecoration::Mode::Server); | ||
1272 | QVERIFY(decoSpy.wait()); | 1272 | QVERIFY(decoSpy.wait()); | ||
Show All 11 Lines | |||||
1284 | QVERIFY(enteredSpy.wait()); | 1284 | QVERIFY(enteredSpy.wait()); | ||
1285 | // click inside window to create serial | 1285 | // click inside window to create serial | ||
1286 | quint32 timestamp = 0; | 1286 | quint32 timestamp = 0; | ||
1287 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 1287 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
1288 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1288 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1289 | QVERIFY(buttonStateChangedSpy.wait()); | 1289 | QVERIFY(buttonStateChangedSpy.wait()); | ||
1290 | 1290 | | |||
1291 | // now create the popup surface | 1291 | // now create the popup surface | ||
1292 | XdgPositioner positioner(QSize(100, 50), QRect(0, 0, 80, 20)); | ||||
1293 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
1294 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
1292 | Surface *popupSurface = Test::createSurface(m_compositor); | 1295 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1293 | QVERIFY(popupSurface); | 1296 | QVERIFY(popupSurface); | ||
1294 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | 1297 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1295 | QVERIFY(popupShellSurface); | 1298 | QVERIFY(popupShellSurface); | ||
1296 | QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); | 1299 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1297 | QVERIFY(popupDoneSpy.isValid()); | 1300 | QVERIFY(popupDoneSpy.isValid()); | ||
1298 | // TODO: proper serial | 1301 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1299 | popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); | 1302 | render(popupSurface, positioner.initialSize()); | ||
1300 | render(popupSurface); | | |||
1301 | QVERIFY(clientAddedSpy.wait()); | 1303 | QVERIFY(clientAddedSpy.wait()); | ||
1302 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1304 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||
1303 | QVERIFY(popupClient); | 1305 | QVERIFY(popupClient); | ||
1304 | QVERIFY(popupClient != window); | 1306 | QVERIFY(popupClient != window); | ||
1305 | QCOMPARE(window, workspace()->activeClient()); | 1307 | QCOMPARE(window, workspace()->activeClient()); | ||
1306 | QCOMPARE(popupClient->transientFor(), window); | 1308 | QCOMPARE(popupClient->transientFor(), window); | ||
1307 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | 1309 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | ||
1308 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1310 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
Show All 22 Lines | 1321 | { | |||
1331 | QSignalSpy leftSpy(pointer, &Pointer::left); | 1333 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||
1332 | QVERIFY(leftSpy.isValid()); | 1334 | QVERIFY(leftSpy.isValid()); | ||
1333 | 1335 | | |||
1334 | Cursor::setPos(800, 800); | 1336 | Cursor::setPos(800, 800); | ||
1335 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 1337 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
1336 | QVERIFY(clientAddedSpy.isValid()); | 1338 | QVERIFY(clientAddedSpy.isValid()); | ||
1337 | Surface *surface = Test::createSurface(m_compositor); | 1339 | Surface *surface = Test::createSurface(m_compositor); | ||
1338 | QVERIFY(surface); | 1340 | QVERIFY(surface); | ||
1339 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 1341 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface); | ||
1340 | QVERIFY(shellSurface); | 1342 | QVERIFY(shellSurface); | ||
1341 | render(surface); | 1343 | render(surface); | ||
1342 | QVERIFY(clientAddedSpy.wait()); | 1344 | QVERIFY(clientAddedSpy.wait()); | ||
1343 | AbstractClient *window = workspace()->activeClient(); | 1345 | AbstractClient *window = workspace()->activeClient(); | ||
1344 | QVERIFY(window); | 1346 | QVERIFY(window); | ||
1345 | 1347 | | |||
1346 | // move cursor over window | 1348 | // move cursor over window | ||
1347 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 1349 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
1348 | Cursor::setPos(window->geometry().center()); | 1350 | Cursor::setPos(window->geometry().center()); | ||
1349 | QVERIFY(enteredSpy.wait()); | 1351 | QVERIFY(enteredSpy.wait()); | ||
1350 | // click inside window | 1352 | // click inside window | ||
1351 | quint32 timestamp = 0; | 1353 | quint32 timestamp = 0; | ||
1352 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | 1354 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||
1353 | 1355 | | |||
1354 | // now create a second window as transient | 1356 | // now create a second window as transient | ||
1357 | XdgPositioner positioner(QSize(99, 49), QRect(0, 0, 1, 1)); | ||||
1358 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||||
1359 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||||
1355 | Surface *popupSurface = Test::createSurface(m_compositor); | 1360 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1356 | QVERIFY(popupSurface); | 1361 | QVERIFY(popupSurface); | ||
1357 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | 1362 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1358 | QVERIFY(popupShellSurface); | 1363 | QVERIFY(popupShellSurface); | ||
1359 | popupShellSurface->setTransient(surface, QPoint(0, 0)); | 1364 | render(popupSurface, positioner.initialSize()); | ||
1360 | render(popupSurface); | | |||
1361 | QVERIFY(clientAddedSpy.wait()); | 1365 | QVERIFY(clientAddedSpy.wait()); | ||
1362 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1366 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||
1363 | QVERIFY(popupClient); | 1367 | QVERIFY(popupClient); | ||
1364 | QVERIFY(popupClient != window); | 1368 | QVERIFY(popupClient != window); | ||
1365 | QCOMPARE(window->geometry(), popupClient->geometry()); | 1369 | QVERIFY(window->geometry().contains(Cursor::pos())); | ||
1370 | QVERIFY(popupClient->geometry().contains(Cursor::pos())); | ||||
1366 | QVERIFY(!leftSpy.wait()); | 1371 | QVERIFY(!leftSpy.wait()); | ||
1367 | 1372 | | |||
1368 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1373 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1369 | // now that the button is no longer pressed we should get the leave event | 1374 | // now that the button is no longer pressed we should get the leave event | ||
1370 | QVERIFY(leftSpy.wait()); | 1375 | QVERIFY(leftSpy.wait()); | ||
1371 | QCOMPARE(leftSpy.count(), 1); | 1376 | QCOMPARE(leftSpy.count(), 1); | ||
1372 | QCOMPARE(enteredSpy.count(), 2); | 1377 | QCOMPARE(enteredSpy.count(), 2); | ||
1373 | } | 1378 | } | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 1557 | { | |||
1593 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | 1598 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||
1594 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1599 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1595 | QVERIFY(!c->isMove()); | 1600 | QVERIFY(!c->isMove()); | ||
1596 | 1601 | | |||
1597 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | 1602 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | ||
1598 | QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); | 1603 | QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); | ||
1599 | } | 1604 | } | ||
1600 | 1605 | | |||
1606 | void PointerInputTest::testHideShowCursor() | ||||
1607 | { | ||||
1608 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), false); | ||||
1609 | kwinApp()->platform()->hideCursor(); | ||||
1610 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1611 | kwinApp()->platform()->showCursor(); | ||||
1612 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), false); | ||||
1613 | | ||||
1614 | kwinApp()->platform()->hideCursor(); | ||||
1615 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1616 | kwinApp()->platform()->hideCursor(); | ||||
1617 | kwinApp()->platform()->hideCursor(); | ||||
1618 | kwinApp()->platform()->hideCursor(); | ||||
1619 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1620 | | ||||
1621 | kwinApp()->platform()->showCursor(); | ||||
1622 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1623 | kwinApp()->platform()->showCursor(); | ||||
1624 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1625 | kwinApp()->platform()->showCursor(); | ||||
1626 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), true); | ||||
1627 | kwinApp()->platform()->showCursor(); | ||||
1628 | QCOMPARE(kwinApp()->platform()->isCursorHidden(), false); | ||||
1629 | } | ||||
1630 | | ||||
1601 | } | 1631 | } | ||
1602 | 1632 | | |||
1603 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | 1633 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | ||
1604 | #include "pointer_input.moc" | 1634 | #include "pointer_input.moc" |