Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/input_stacking_order.cpp
Show All 28 Lines | |||||
29 | #include "shell_client.h" | 29 | #include "shell_client.h" | ||
30 | #include <kwineffects.h> | 30 | #include <kwineffects.h> | ||
31 | 31 | | |||
32 | #include <KWayland/Client/connection_thread.h> | 32 | #include <KWayland/Client/connection_thread.h> | ||
33 | #include <KWayland/Client/compositor.h> | 33 | #include <KWayland/Client/compositor.h> | ||
34 | #include <KWayland/Client/event_queue.h> | 34 | #include <KWayland/Client/event_queue.h> | ||
35 | #include <KWayland/Client/registry.h> | 35 | #include <KWayland/Client/registry.h> | ||
36 | #include <KWayland/Client/pointer.h> | 36 | #include <KWayland/Client/pointer.h> | ||
37 | #include <KWayland/Client/shell.h> | | |||
38 | #include <KWayland/Client/seat.h> | 37 | #include <KWayland/Client/seat.h> | ||
39 | #include <KWayland/Client/shm_pool.h> | 38 | #include <KWayland/Client/shm_pool.h> | ||
40 | #include <KWayland/Client/surface.h> | 39 | #include <KWayland/Client/surface.h> | ||
41 | 40 | | |||
42 | #include <KWayland/Server/seat_interface.h> | 41 | #include <KWayland/Server/seat_interface.h> | ||
43 | 42 | | |||
44 | namespace KWin | 43 | namespace KWin | ||
45 | { | 44 | { | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
98 | void InputStackingOrderTest::render(KWayland::Client::Surface *surface) | 97 | void InputStackingOrderTest::render(KWayland::Client::Surface *surface) | ||
99 | { | 98 | { | ||
100 | Test::render(surface, QSize(100, 50), Qt::blue); | 99 | Test::render(surface, QSize(100, 50), Qt::blue); | ||
101 | Test::flushWaylandConnection(); | 100 | Test::flushWaylandConnection(); | ||
102 | } | 101 | } | ||
103 | 102 | | |||
104 | void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange_data() | 103 | void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange_data() | ||
105 | { | 104 | { | ||
106 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 105 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
107 | 106 | | |||
108 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 107 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
109 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 108 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
109 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange() | 112 | void InputStackingOrderTest::testPointerFocusUpdatesOnStackingOrderChange() | ||
113 | { | 113 | { | ||
114 | // this test creates two windows which overlap | 114 | // this test creates two windows which overlap | ||
115 | // the pointer is in the overlapping area which means the top most window has focus | 115 | // the pointer is in the overlapping area which means the top most window has focus | ||
116 | // as soon as the top most window gets lowered the window should lose focus and the | 116 | // as soon as the top most window gets lowered the window should lose focus and the | ||
117 | // other window should gain focus without a mouse event in between | 117 | // other window should gain focus without a mouse event in between | ||
118 | using namespace KWayland::Client; | 118 | using namespace KWayland::Client; | ||
119 | // create pointer and signal spy for enter and leave signals | 119 | // create pointer and signal spy for enter and leave signals | ||
120 | auto pointer = Test::waylandSeat()->createPointer(Test::waylandSeat()); | 120 | auto pointer = Test::waylandSeat()->createPointer(Test::waylandSeat()); | ||
121 | QVERIFY(pointer); | 121 | QVERIFY(pointer); | ||
122 | QVERIFY(pointer->isValid()); | 122 | QVERIFY(pointer->isValid()); | ||
123 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | 123 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||
124 | QVERIFY(enteredSpy.isValid()); | 124 | QVERIFY(enteredSpy.isValid()); | ||
125 | QSignalSpy leftSpy(pointer, &Pointer::left); | 125 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||
126 | QVERIFY(leftSpy.isValid()); | 126 | QVERIFY(leftSpy.isValid()); | ||
127 | 127 | | |||
128 | // now create the two windows and make them overlap | 128 | // now create the two windows and make them overlap | ||
129 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 129 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
130 | QVERIFY(clientAddedSpy.isValid()); | 130 | QVERIFY(clientAddedSpy.isValid()); | ||
131 | Surface *surface1 = Test::createSurface(Test::waylandCompositor()); | 131 | Surface *surface1 = Test::createSurface(Test::waylandCompositor()); | ||
132 | QVERIFY(surface1); | 132 | QVERIFY(surface1); | ||
133 | QFETCH(Test::ShellSurfaceType, type); | 133 | QFETCH(Test::XdgShellSurfaceType, type); | ||
134 | auto shellSurface1 = Test::createShellSurface(type, surface1, surface1); | 134 | XdgShellSurface *shellSurface1 = Test::createXdgShellSurface(type, surface1, surface1); | ||
135 | QVERIFY(shellSurface1); | 135 | QVERIFY(shellSurface1); | ||
136 | render(surface1); | 136 | render(surface1); | ||
137 | QVERIFY(clientAddedSpy.wait()); | 137 | QVERIFY(clientAddedSpy.wait()); | ||
138 | AbstractClient *window1 = workspace()->activeClient(); | 138 | AbstractClient *window1 = workspace()->activeClient(); | ||
139 | QVERIFY(window1); | 139 | QVERIFY(window1); | ||
140 | 140 | | |||
141 | Surface *surface2 = Test::createSurface(Test::waylandCompositor()); | 141 | Surface *surface2 = Test::createSurface(Test::waylandCompositor()); | ||
142 | QVERIFY(surface2); | 142 | QVERIFY(surface2); | ||
143 | auto shellSurface2 = Test::createShellSurface(type, surface2, surface2); | 143 | XdgShellSurface *shellSurface2 = Test::createXdgShellSurface(type, surface2, surface2); | ||
144 | QVERIFY(shellSurface2); | 144 | QVERIFY(shellSurface2); | ||
145 | render(surface2); | 145 | render(surface2); | ||
146 | QVERIFY(clientAddedSpy.wait()); | 146 | QVERIFY(clientAddedSpy.wait()); | ||
147 | 147 | | |||
148 | AbstractClient *window2 = workspace()->activeClient(); | 148 | AbstractClient *window2 = workspace()->activeClient(); | ||
149 | QVERIFY(window2); | 149 | QVERIFY(window2); | ||
150 | QVERIFY(window1 != window2); | 150 | QVERIFY(window1 != window2); | ||
151 | 151 | | |||
Show All 39 Lines |