Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show All 27 Lines | |||||
28 | #include "screens.h" | 28 | #include "screens.h" | ||
29 | #include "wayland_server.h" | 29 | #include "wayland_server.h" | ||
30 | #include "workspace.h" | 30 | #include "workspace.h" | ||
31 | #include "shell_client.h" | 31 | #include "shell_client.h" | ||
32 | #include <kwineffects.h> | 32 | #include <kwineffects.h> | ||
33 | 33 | | |||
34 | #include <KWayland/Client/connection_thread.h> | 34 | #include <KWayland/Client/connection_thread.h> | ||
35 | #include <KWayland/Client/compositor.h> | 35 | #include <KWayland/Client/compositor.h> | ||
36 | #include <KWayland/Client/event_queue.h> | | |||
37 | #include <KWayland/Client/registry.h> | | |||
38 | #include <KWayland/Client/pointer.h> | 36 | #include <KWayland/Client/pointer.h> | ||
39 | #include <KWayland/Client/shell.h> | 37 | #include <KWayland/Client/shell.h> | ||
40 | #include <KWayland/Client/seat.h> | 38 | #include <KWayland/Client/seat.h> | ||
41 | #include <KWayland/Client/shm_pool.h> | 39 | #include <KWayland/Client/shm_pool.h> | ||
42 | #include <KWayland/Client/surface.h> | 40 | #include <KWayland/Client/surface.h> | ||
43 | 41 | | |||
44 | #include <KWayland/Server/seat_interface.h> | 42 | #include <KWayland/Server/seat_interface.h> | ||
45 | 43 | | |||
Show All 24 Lines | 54 | private Q_SLOTS: | |||
70 | void testMouseActionInactiveWindow(); | 68 | void testMouseActionInactiveWindow(); | ||
71 | void testMouseActionActiveWindow_data(); | 69 | void testMouseActionActiveWindow_data(); | ||
72 | void testMouseActionActiveWindow(); | 70 | void testMouseActionActiveWindow(); | ||
73 | void testCursorImage(); | 71 | void testCursorImage(); | ||
74 | void testEffectOverrideCursorImage(); | 72 | void testEffectOverrideCursorImage(); | ||
75 | 73 | | |||
76 | private: | 74 | private: | ||
77 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | 75 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | ||
78 | KWayland::Client::ConnectionThread *m_connection = nullptr; | | |||
79 | KWayland::Client::Compositor *m_compositor = nullptr; | 76 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
80 | KWayland::Client::Seat *m_seat = nullptr; | 77 | KWayland::Client::Seat *m_seat = nullptr; | ||
81 | KWayland::Client::ShmPool *m_shm = nullptr; | | |||
82 | KWayland::Client::Shell *m_shell = nullptr; | 78 | KWayland::Client::Shell *m_shell = nullptr; | ||
83 | KWayland::Client::EventQueue *m_queue = nullptr; | | |||
84 | QThread *m_thread = nullptr; | | |||
85 | }; | 79 | }; | ||
86 | 80 | | |||
87 | void PointerInputTest::initTestCase() | 81 | void PointerInputTest::initTestCase() | ||
88 | { | 82 | { | ||
89 | qRegisterMetaType<KWin::ShellClient*>(); | 83 | qRegisterMetaType<KWin::ShellClient*>(); | ||
90 | qRegisterMetaType<KWin::AbstractClient*>(); | 84 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
91 | qRegisterMetaType<KWin::Deleted*>(); | 85 | qRegisterMetaType<KWin::Deleted*>(); | ||
92 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 86 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
Show All 13 Lines | |||||
106 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 100 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
107 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 101 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
108 | setenv("QT_QPA_PLATFORM", "wayland", true); | 102 | setenv("QT_QPA_PLATFORM", "wayland", true); | ||
109 | waylandServer()->initWorkspace(); | 103 | waylandServer()->initWorkspace(); | ||
110 | } | 104 | } | ||
111 | 105 | | |||
112 | void PointerInputTest::init() | 106 | void PointerInputTest::init() | ||
113 | { | 107 | { | ||
114 | using namespace KWayland::Client; | 108 | QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::Seat)); | ||
115 | // setup connection | 109 | QVERIFY(Test::waitForWaylandPointer()); | ||
116 | m_connection = new ConnectionThread; | 110 | m_compositor = Test::waylandCompositor(); | ||
117 | QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected); | 111 | m_shell = Test::waylandShell(); | ||
118 | QVERIFY(connectedSpy.isValid()); | 112 | m_seat = Test::waylandSeat(); | ||
119 | m_connection->setSocketName(s_socketName); | | |||
120 | | ||||
121 | m_thread = new QThread(this); | | |||
122 | m_connection->moveToThread(m_thread); | | |||
123 | m_thread->start(); | | |||
124 | | ||||
125 | m_connection->initConnection(); | | |||
126 | QVERIFY(connectedSpy.wait()); | | |||
127 | | ||||
128 | m_queue = new EventQueue(this); | | |||
129 | QVERIFY(!m_queue->isValid()); | | |||
130 | m_queue->setup(m_connection); | | |||
131 | QVERIFY(m_queue->isValid()); | | |||
132 | | ||||
133 | Registry registry; | | |||
134 | registry.setEventQueue(m_queue); | | |||
135 | QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced); | | |||
136 | QSignalSpy shmSpy(®istry, &Registry::shmAnnounced); | | |||
137 | QSignalSpy shellSpy(®istry, &Registry::shellAnnounced); | | |||
138 | QSignalSpy seatSpy(®istry, &Registry::seatAnnounced); | | |||
139 | QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced); | | |||
140 | QVERIFY(allAnnounced.isValid()); | | |||
141 | QVERIFY(shmSpy.isValid()); | | |||
142 | QVERIFY(shellSpy.isValid()); | | |||
143 | QVERIFY(compositorSpy.isValid()); | | |||
144 | QVERIFY(seatSpy.isValid()); | | |||
145 | registry.create(m_connection->display()); | | |||
146 | QVERIFY(registry.isValid()); | | |||
147 | registry.setup(); | | |||
148 | QVERIFY(allAnnounced.wait()); | | |||
149 | QVERIFY(!compositorSpy.isEmpty()); | | |||
150 | QVERIFY(!shmSpy.isEmpty()); | | |||
151 | QVERIFY(!shellSpy.isEmpty()); | | |||
152 | QVERIFY(!seatSpy.isEmpty()); | | |||
153 | | ||||
154 | m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this); | | |||
155 | QVERIFY(m_compositor->isValid()); | | |||
156 | m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this); | | |||
157 | QVERIFY(m_shm->isValid()); | | |||
158 | m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this); | | |||
159 | QVERIFY(m_shell->isValid()); | | |||
160 | m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this); | | |||
161 | QVERIFY(m_seat->isValid()); | | |||
162 | QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged); | | |||
163 | QVERIFY(hasPointerSpy.isValid()); | | |||
164 | QVERIFY(hasPointerSpy.wait()); | | |||
165 | 113 | | |||
166 | screens()->setCurrent(0); | 114 | screens()->setCurrent(0); | ||
167 | Cursor::setPos(QPoint(640, 512)); | 115 | Cursor::setPos(QPoint(640, 512)); | ||
168 | } | 116 | } | ||
169 | 117 | | |||
170 | void PointerInputTest::cleanup() | 118 | void PointerInputTest::cleanup() | ||
171 | { | 119 | { | ||
172 | delete m_compositor; | 120 | Test::destroyWaylandConnection(); | ||
173 | m_compositor = nullptr; | | |||
174 | delete m_seat; | | |||
175 | m_seat = nullptr; | | |||
176 | delete m_shm; | | |||
177 | m_shm = nullptr; | | |||
178 | delete m_shell; | | |||
179 | m_shell = nullptr; | | |||
180 | delete m_queue; | | |||
181 | m_queue = nullptr; | | |||
182 | if (m_thread) { | | |||
183 | m_connection->deleteLater(); | | |||
184 | m_thread->quit(); | | |||
185 | m_thread->wait(); | | |||
186 | delete m_thread; | | |||
187 | m_thread = nullptr; | | |||
188 | m_connection = nullptr; | | |||
189 | } | | |||
190 | } | 121 | } | ||
191 | 122 | | |||
192 | void PointerInputTest::render(KWayland::Client::Surface *surface, const QSize &size) | 123 | void PointerInputTest::render(KWayland::Client::Surface *surface, const QSize &size) | ||
193 | { | 124 | { | ||
194 | QImage img(size, QImage::Format_ARGB32); | 125 | Test::render(surface, size, Qt::blue); | ||
195 | img.fill(Qt::blue); | 126 | Test::flushWaylandConnection(); | ||
196 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
197 | surface->damage(QRect(QPoint(0, 0), size)); | | |||
198 | surface->commit(KWayland::Client::Surface::CommitFlag::None); | | |||
199 | m_connection->flush(); | | |||
200 | } | 127 | } | ||
201 | 128 | | |||
202 | void PointerInputTest::testWarpingUpdatesFocus() | 129 | void PointerInputTest::testWarpingUpdatesFocus() | ||
203 | { | 130 | { | ||
204 | // this test verifies that warping the pointer creates pointer enter and leave events | 131 | // this test verifies that warping the pointer creates pointer enter and leave events | ||
205 | using namespace KWayland::Client; | 132 | using namespace KWayland::Client; | ||
206 | // create pointer and signal spy for enter and leave signals | 133 | // create pointer and signal spy for enter and leave signals | ||
207 | auto pointer = m_seat->createPointer(m_seat); | 134 | auto pointer = m_seat->createPointer(m_seat); | ||
208 | QVERIFY(pointer); | 135 | QVERIFY(pointer); | ||
209 | QVERIFY(pointer->isValid()); | 136 | QVERIFY(pointer->isValid()); | ||
210 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | 137 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||
211 | QVERIFY(enteredSpy.isValid()); | 138 | QVERIFY(enteredSpy.isValid()); | ||
212 | QSignalSpy leftSpy(pointer, &Pointer::left); | 139 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||
213 | QVERIFY(leftSpy.isValid()); | 140 | QVERIFY(leftSpy.isValid()); | ||
214 | 141 | | |||
215 | // create a window | 142 | // create a window | ||
216 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 143 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
217 | QVERIFY(clientAddedSpy.isValid()); | 144 | QVERIFY(clientAddedSpy.isValid()); | ||
218 | Surface *surface = m_compositor->createSurface(m_compositor); | 145 | Surface *surface = Test::createSurface(m_compositor); | ||
219 | QVERIFY(surface); | 146 | QVERIFY(surface); | ||
220 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 147 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
221 | QVERIFY(shellSurface); | 148 | QVERIFY(shellSurface); | ||
222 | render(surface); | 149 | render(surface); | ||
223 | QVERIFY(clientAddedSpy.wait()); | 150 | QVERIFY(clientAddedSpy.wait()); | ||
224 | AbstractClient *window = workspace()->activeClient(); | 151 | AbstractClient *window = workspace()->activeClient(); | ||
225 | QVERIFY(window); | 152 | QVERIFY(window); | ||
226 | 153 | | |||
227 | // currently there should not be a focused pointer surface | 154 | // currently there should not be a focused pointer surface | ||
228 | QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); | 155 | QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); | ||
Show All 28 Lines | 177 | { | |||
257 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | 184 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||
258 | QVERIFY(enteredSpy.isValid()); | 185 | QVERIFY(enteredSpy.isValid()); | ||
259 | QSignalSpy movedSpy(pointer, &Pointer::motion); | 186 | QSignalSpy movedSpy(pointer, &Pointer::motion); | ||
260 | QVERIFY(movedSpy.isValid()); | 187 | QVERIFY(movedSpy.isValid()); | ||
261 | 188 | | |||
262 | // create a window | 189 | // create a window | ||
263 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 190 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
264 | QVERIFY(clientAddedSpy.isValid()); | 191 | QVERIFY(clientAddedSpy.isValid()); | ||
265 | Surface *surface = m_compositor->createSurface(m_compositor); | 192 | Surface *surface = Test::createSurface(m_compositor); | ||
266 | QVERIFY(surface); | 193 | QVERIFY(surface); | ||
267 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 194 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
268 | QVERIFY(shellSurface); | 195 | QVERIFY(shellSurface); | ||
269 | render(surface); | 196 | render(surface); | ||
270 | QVERIFY(clientAddedSpy.wait()); | 197 | QVERIFY(clientAddedSpy.wait()); | ||
271 | AbstractClient *window = workspace()->activeClient(); | 198 | AbstractClient *window = workspace()->activeClient(); | ||
272 | QVERIFY(window); | 199 | QVERIFY(window); | ||
273 | 200 | | |||
274 | // enter | 201 | // enter | ||
275 | kwinApp()->platform()->pointerMotion(QPointF(25, 25), 1); | 202 | kwinApp()->platform()->pointerMotion(QPointF(25, 25), 1); | ||
Show All 23 Lines | 217 | { | |||
299 | QVERIFY(pointer); | 226 | QVERIFY(pointer); | ||
300 | QVERIFY(pointer->isValid()); | 227 | QVERIFY(pointer->isValid()); | ||
301 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | 228 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||
302 | QVERIFY(enteredSpy.isValid()); | 229 | QVERIFY(enteredSpy.isValid()); | ||
303 | 230 | | |||
304 | // create a window | 231 | // create a window | ||
305 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 232 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
306 | QVERIFY(clientAddedSpy.isValid()); | 233 | QVERIFY(clientAddedSpy.isValid()); | ||
307 | Surface *surface = m_compositor->createSurface(m_compositor); | 234 | Surface *surface = Test::createSurface(m_compositor); | ||
308 | QVERIFY(surface); | 235 | QVERIFY(surface); | ||
309 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 236 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
310 | QVERIFY(shellSurface); | 237 | QVERIFY(shellSurface); | ||
311 | render(surface, QSize(1280, 1024)); | 238 | render(surface, QSize(1280, 1024)); | ||
312 | QVERIFY(clientAddedSpy.wait()); | 239 | QVERIFY(clientAddedSpy.wait()); | ||
313 | AbstractClient *window = workspace()->activeClient(); | 240 | AbstractClient *window = workspace()->activeClient(); | ||
314 | QVERIFY(window); | 241 | QVERIFY(window); | ||
315 | QVERIFY(!window->geometry().contains(Cursor::pos())); | 242 | QVERIFY(!window->geometry().contains(Cursor::pos())); | ||
316 | 243 | | |||
317 | QSignalSpy screensChangedSpy(screens(), &Screens::changed); | 244 | QSignalSpy screensChangedSpy(screens(), &Screens::changed); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 286 | { | |||
378 | QCOMPARE(options->commandAllModifier(), modKey == QStringLiteral("Alt") ? Qt::AltModifier : Qt::MetaModifier); | 305 | QCOMPARE(options->commandAllModifier(), modKey == QStringLiteral("Alt") ? Qt::AltModifier : Qt::MetaModifier); | ||
379 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | 306 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||
380 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | 307 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||
381 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | 308 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||
382 | 309 | | |||
383 | // create a window | 310 | // create a window | ||
384 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 311 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
385 | QVERIFY(clientAddedSpy.isValid()); | 312 | QVERIFY(clientAddedSpy.isValid()); | ||
386 | Surface *surface = m_compositor->createSurface(m_compositor); | 313 | Surface *surface = Test::createSurface(m_compositor); | ||
387 | QVERIFY(surface); | 314 | QVERIFY(surface); | ||
388 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 315 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
389 | QVERIFY(shellSurface); | 316 | QVERIFY(shellSurface); | ||
390 | render(surface); | 317 | render(surface); | ||
391 | QVERIFY(clientAddedSpy.wait()); | 318 | QVERIFY(clientAddedSpy.wait()); | ||
392 | AbstractClient *window = workspace()->activeClient(); | 319 | AbstractClient *window = workspace()->activeClient(); | ||
393 | QVERIFY(window); | 320 | QVERIFY(window); | ||
394 | 321 | | |||
395 | // move cursor on window | 322 | // move cursor on window | ||
396 | Cursor::setPos(window->geometry().center()); | 323 | Cursor::setPos(window->geometry().center()); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 361 | { | |||
448 | group.writeEntry("CommandAllKey", modKey); | 375 | group.writeEntry("CommandAllKey", modKey); | ||
449 | group.writeEntry("CommandAllWheel", "change opacity"); | 376 | group.writeEntry("CommandAllWheel", "change opacity"); | ||
450 | group.sync(); | 377 | group.sync(); | ||
451 | workspace()->slotReconfigure(); | 378 | workspace()->slotReconfigure(); | ||
452 | 379 | | |||
453 | // create a window | 380 | // create a window | ||
454 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 381 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
455 | QVERIFY(clientAddedSpy.isValid()); | 382 | QVERIFY(clientAddedSpy.isValid()); | ||
456 | Surface *surface = m_compositor->createSurface(m_compositor); | 383 | Surface *surface = Test::createSurface(m_compositor); | ||
457 | QVERIFY(surface); | 384 | QVERIFY(surface); | ||
458 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 385 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
459 | QVERIFY(shellSurface); | 386 | QVERIFY(shellSurface); | ||
460 | render(surface); | 387 | render(surface); | ||
461 | QVERIFY(clientAddedSpy.wait()); | 388 | QVERIFY(clientAddedSpy.wait()); | ||
462 | AbstractClient *window = workspace()->activeClient(); | 389 | AbstractClient *window = workspace()->activeClient(); | ||
463 | QVERIFY(window); | 390 | QVERIFY(window); | ||
464 | // set the opacity to 0.5 | 391 | // set the opacity to 0.5 | ||
465 | window->setOpacity(0.5); | 392 | window->setOpacity(0.5); | ||
466 | QCOMPARE(window->opacity(), 0.5); | 393 | QCOMPARE(window->opacity(), 0.5); | ||
Show All 29 Lines | 414 | { | |||
496 | // first modify the config for this run | 423 | // first modify the config for this run | ||
497 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | 424 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||
498 | group.writeEntry("CommandWindowWheel", "activate and scroll"); | 425 | group.writeEntry("CommandWindowWheel", "activate and scroll"); | ||
499 | group.sync(); | 426 | group.sync(); | ||
500 | workspace()->slotReconfigure(); | 427 | workspace()->slotReconfigure(); | ||
501 | // create two windows | 428 | // create two windows | ||
502 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 429 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
503 | QVERIFY(clientAddedSpy.isValid()); | 430 | QVERIFY(clientAddedSpy.isValid()); | ||
504 | Surface *surface1 = m_compositor->createSurface(m_compositor); | 431 | Surface *surface1 = Test::createSurface(m_compositor); | ||
505 | QVERIFY(surface1); | 432 | QVERIFY(surface1); | ||
506 | ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1); | 433 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | ||
507 | QVERIFY(shellSurface1); | 434 | QVERIFY(shellSurface1); | ||
508 | render(surface1); | 435 | render(surface1); | ||
509 | QVERIFY(clientAddedSpy.wait()); | 436 | QVERIFY(clientAddedSpy.wait()); | ||
510 | AbstractClient *window1 = workspace()->activeClient(); | 437 | AbstractClient *window1 = workspace()->activeClient(); | ||
511 | QVERIFY(window1); | 438 | QVERIFY(window1); | ||
512 | Surface *surface2 = m_compositor->createSurface(m_compositor); | 439 | Surface *surface2 = Test::createSurface(m_compositor); | ||
513 | QVERIFY(surface2); | 440 | QVERIFY(surface2); | ||
514 | ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2); | 441 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | ||
515 | QVERIFY(shellSurface2); | 442 | QVERIFY(shellSurface2); | ||
516 | render(surface2); | 443 | render(surface2); | ||
517 | QVERIFY(clientAddedSpy.wait()); | 444 | QVERIFY(clientAddedSpy.wait()); | ||
518 | AbstractClient *window2 = workspace()->activeClient(); | 445 | AbstractClient *window2 = workspace()->activeClient(); | ||
519 | QVERIFY(window2); | 446 | QVERIFY(window2); | ||
520 | QVERIFY(window1 != window2); | 447 | QVERIFY(window1 != window2); | ||
521 | 448 | | |||
522 | // move cursor to the inactive window | 449 | // move cursor to the inactive window | ||
Show All 33 Lines | 465 | { | |||
556 | QCOMPARE(options->focusPolicy(), Options::FocusFollowsMouse); | 483 | QCOMPARE(options->focusPolicy(), Options::FocusFollowsMouse); | ||
557 | QVERIFY(options->isAutoRaise()); | 484 | QVERIFY(options->isAutoRaise()); | ||
558 | QCOMPARE(options->autoRaiseInterval(), 20); | 485 | QCOMPARE(options->autoRaiseInterval(), 20); | ||
559 | QCOMPARE(options->delayFocusInterval(), 200); | 486 | QCOMPARE(options->delayFocusInterval(), 200); | ||
560 | 487 | | |||
561 | // create two windows | 488 | // create two windows | ||
562 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 489 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
563 | QVERIFY(clientAddedSpy.isValid()); | 490 | QVERIFY(clientAddedSpy.isValid()); | ||
564 | Surface *surface1 = m_compositor->createSurface(m_compositor); | 491 | Surface *surface1 = Test::createSurface(m_compositor); | ||
565 | QVERIFY(surface1); | 492 | QVERIFY(surface1); | ||
566 | ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1); | 493 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | ||
567 | QVERIFY(shellSurface1); | 494 | QVERIFY(shellSurface1); | ||
568 | render(surface1, QSize(800, 800)); | 495 | render(surface1, QSize(800, 800)); | ||
569 | QVERIFY(clientAddedSpy.wait()); | 496 | QVERIFY(clientAddedSpy.wait()); | ||
570 | AbstractClient *window1 = workspace()->activeClient(); | 497 | AbstractClient *window1 = workspace()->activeClient(); | ||
571 | QVERIFY(window1); | 498 | QVERIFY(window1); | ||
572 | Surface *surface2 = m_compositor->createSurface(m_compositor); | 499 | Surface *surface2 = Test::createSurface(m_compositor); | ||
573 | QVERIFY(surface2); | 500 | QVERIFY(surface2); | ||
574 | ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2); | 501 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | ||
575 | QVERIFY(shellSurface2); | 502 | QVERIFY(shellSurface2); | ||
576 | render(surface2, QSize(800, 800)); | 503 | render(surface2, QSize(800, 800)); | ||
577 | QVERIFY(clientAddedSpy.wait()); | 504 | QVERIFY(clientAddedSpy.wait()); | ||
578 | AbstractClient *window2 = workspace()->activeClient(); | 505 | AbstractClient *window2 = workspace()->activeClient(); | ||
579 | QVERIFY(window2); | 506 | QVERIFY(window2); | ||
580 | QVERIFY(window1 != window2); | 507 | QVERIFY(window1 != window2); | ||
581 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | 508 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | ||
582 | // geometry of the two windows should be overlapping | 509 | // geometry of the two windows should be overlapping | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 558 | { | |||
642 | group.writeEntry("CommandWindow2", "Activate, raise and pass click"); | 569 | group.writeEntry("CommandWindow2", "Activate, raise and pass click"); | ||
643 | group.writeEntry("CommandWindow3", "Activate, raise and pass click"); | 570 | group.writeEntry("CommandWindow3", "Activate, raise and pass click"); | ||
644 | group.sync(); | 571 | group.sync(); | ||
645 | workspace()->slotReconfigure(); | 572 | workspace()->slotReconfigure(); | ||
646 | 573 | | |||
647 | // create two windows | 574 | // create two windows | ||
648 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 575 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
649 | QVERIFY(clientAddedSpy.isValid()); | 576 | QVERIFY(clientAddedSpy.isValid()); | ||
650 | Surface *surface1 = m_compositor->createSurface(m_compositor); | 577 | Surface *surface1 = Test::createSurface(m_compositor); | ||
651 | QVERIFY(surface1); | 578 | QVERIFY(surface1); | ||
652 | ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1); | 579 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | ||
653 | QVERIFY(shellSurface1); | 580 | QVERIFY(shellSurface1); | ||
654 | render(surface1, QSize(800, 800)); | 581 | render(surface1, QSize(800, 800)); | ||
655 | QVERIFY(clientAddedSpy.wait()); | 582 | QVERIFY(clientAddedSpy.wait()); | ||
656 | AbstractClient *window1 = workspace()->activeClient(); | 583 | AbstractClient *window1 = workspace()->activeClient(); | ||
657 | QVERIFY(window1); | 584 | QVERIFY(window1); | ||
658 | Surface *surface2 = m_compositor->createSurface(m_compositor); | 585 | Surface *surface2 = Test::createSurface(m_compositor); | ||
659 | QVERIFY(surface2); | 586 | QVERIFY(surface2); | ||
660 | ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2); | 587 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | ||
661 | QVERIFY(shellSurface2); | 588 | QVERIFY(shellSurface2); | ||
662 | render(surface2, QSize(800, 800)); | 589 | render(surface2, QSize(800, 800)); | ||
663 | QVERIFY(clientAddedSpy.wait()); | 590 | QVERIFY(clientAddedSpy.wait()); | ||
664 | AbstractClient *window2 = workspace()->activeClient(); | 591 | AbstractClient *window2 = workspace()->activeClient(); | ||
665 | QVERIFY(window2); | 592 | QVERIFY(window2); | ||
666 | QVERIFY(window1 != window2); | 593 | QVERIFY(window1 != window2); | ||
667 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | 594 | QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); | ||
668 | // geometry of the two windows should be overlapping | 595 | // geometry of the two windows should be overlapping | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 644 | { | |||
732 | group.writeEntry("ClickRaise", clickRaise); | 659 | group.writeEntry("ClickRaise", clickRaise); | ||
733 | group.sync(); | 660 | group.sync(); | ||
734 | workspace()->slotReconfigure(); | 661 | workspace()->slotReconfigure(); | ||
735 | QCOMPARE(options->isClickRaise(), clickRaise); | 662 | QCOMPARE(options->isClickRaise(), clickRaise); | ||
736 | 663 | | |||
737 | // create two windows | 664 | // create two windows | ||
738 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 665 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
739 | QVERIFY(clientAddedSpy.isValid()); | 666 | QVERIFY(clientAddedSpy.isValid()); | ||
740 | Surface *surface1 = m_compositor->createSurface(m_compositor); | 667 | Surface *surface1 = Test::createSurface(m_compositor); | ||
741 | QVERIFY(surface1); | 668 | QVERIFY(surface1); | ||
742 | ShellSurface *shellSurface1 = m_shell->createSurface(surface1, surface1); | 669 | ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); | ||
743 | QVERIFY(shellSurface1); | 670 | QVERIFY(shellSurface1); | ||
744 | render(surface1, QSize(800, 800)); | 671 | render(surface1, QSize(800, 800)); | ||
745 | QVERIFY(clientAddedSpy.wait()); | 672 | QVERIFY(clientAddedSpy.wait()); | ||
746 | AbstractClient *window1 = workspace()->activeClient(); | 673 | AbstractClient *window1 = workspace()->activeClient(); | ||
747 | QVERIFY(window1); | 674 | QVERIFY(window1); | ||
748 | QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); | 675 | QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); | ||
749 | QVERIFY(window1DestroyedSpy.isValid()); | 676 | QVERIFY(window1DestroyedSpy.isValid()); | ||
750 | Surface *surface2 = m_compositor->createSurface(m_compositor); | 677 | Surface *surface2 = Test::createSurface(m_compositor); | ||
751 | QVERIFY(surface2); | 678 | QVERIFY(surface2); | ||
752 | ShellSurface *shellSurface2 = m_shell->createSurface(surface2, surface2); | 679 | ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); | ||
753 | QVERIFY(shellSurface2); | 680 | QVERIFY(shellSurface2); | ||
754 | render(surface2, QSize(800, 800)); | 681 | render(surface2, QSize(800, 800)); | ||
755 | QVERIFY(clientAddedSpy.wait()); | 682 | QVERIFY(clientAddedSpy.wait()); | ||
756 | AbstractClient *window2 = workspace()->activeClient(); | 683 | AbstractClient *window2 = workspace()->activeClient(); | ||
757 | QVERIFY(window2); | 684 | QVERIFY(window2); | ||
758 | QVERIFY(window1 != window2); | 685 | QVERIFY(window1 != window2); | ||
759 | QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); | 686 | QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); | ||
760 | QVERIFY(window2DestroyedSpy.isValid()); | 687 | QVERIFY(window2DestroyedSpy.isValid()); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 728 | { | |||
812 | Cursor::setPos(800, 800); | 739 | Cursor::setPos(800, 800); | ||
813 | auto p = input()->pointer(); | 740 | auto p = input()->pointer(); | ||
814 | // at the moment it should be the fallback cursor | 741 | // at the moment it should be the fallback cursor | ||
815 | QVERIFY(!p->cursorImage().isNull()); | 742 | QVERIFY(!p->cursorImage().isNull()); | ||
816 | 743 | | |||
817 | // create a window | 744 | // create a window | ||
818 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 745 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
819 | QVERIFY(clientAddedSpy.isValid()); | 746 | QVERIFY(clientAddedSpy.isValid()); | ||
820 | Surface *surface = m_compositor->createSurface(m_compositor); | 747 | Surface *surface = Test::createSurface(m_compositor); | ||
821 | QVERIFY(surface); | 748 | QVERIFY(surface); | ||
822 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 749 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
823 | QVERIFY(shellSurface); | 750 | QVERIFY(shellSurface); | ||
824 | render(surface); | 751 | render(surface); | ||
825 | QVERIFY(clientAddedSpy.wait()); | 752 | QVERIFY(clientAddedSpy.wait()); | ||
826 | AbstractClient *window = workspace()->activeClient(); | 753 | AbstractClient *window = workspace()->activeClient(); | ||
827 | QVERIFY(window); | 754 | QVERIFY(window); | ||
828 | 755 | | |||
829 | // move cursor to center of window, this should first set a null pointer | 756 | // move cursor to center of window, this should first set a null pointer | ||
830 | Cursor::setPos(window->geometry().center()); | 757 | Cursor::setPos(window->geometry().center()); | ||
831 | QCOMPARE(p->window().data(), window); | 758 | QCOMPARE(p->window().data(), window); | ||
832 | QVERIFY(p->cursorImage().isNull()); | 759 | QVERIFY(p->cursorImage().isNull()); | ||
833 | QVERIFY(enteredSpy.wait()); | 760 | QVERIFY(enteredSpy.wait()); | ||
834 | 761 | | |||
835 | // create a cursor on the pointer | 762 | // create a cursor on the pointer | ||
836 | Surface *cursorSurface = m_compositor->createSurface(m_compositor); | 763 | Surface *cursorSurface = Test::createSurface(m_compositor); | ||
837 | QVERIFY(cursorSurface); | 764 | QVERIFY(cursorSurface); | ||
838 | QSignalSpy cursorRenderedSpy(cursorSurface, &Surface::frameRendered); | 765 | QSignalSpy cursorRenderedSpy(cursorSurface, &Surface::frameRendered); | ||
839 | QVERIFY(cursorRenderedSpy.isValid()); | 766 | QVERIFY(cursorRenderedSpy.isValid()); | ||
840 | QImage red = QImage(QSize(10, 10), QImage::Format_ARGB32); | 767 | QImage red = QImage(QSize(10, 10), QImage::Format_ARGB32); | ||
841 | red.fill(Qt::red); | 768 | red.fill(Qt::red); | ||
842 | cursorSurface->attachBuffer(m_shm->createBuffer(red)); | 769 | cursorSurface->attachBuffer(Test::waylandShmPool()->createBuffer(red)); | ||
843 | cursorSurface->damage(QRect(0, 0, 10, 10)); | 770 | cursorSurface->damage(QRect(0, 0, 10, 10)); | ||
844 | cursorSurface->commit(); | 771 | cursorSurface->commit(); | ||
845 | pointer->setCursor(cursorSurface, QPoint(5, 5)); | 772 | pointer->setCursor(cursorSurface, QPoint(5, 5)); | ||
846 | QVERIFY(cursorRenderedSpy.wait()); | 773 | QVERIFY(cursorRenderedSpy.wait()); | ||
847 | QCOMPARE(p->cursorImage(), red); | 774 | QCOMPARE(p->cursorImage(), red); | ||
848 | QCOMPARE(p->cursorHotSpot(), QPoint(5, 5)); | 775 | QCOMPARE(p->cursorHotSpot(), QPoint(5, 5)); | ||
849 | // change hotspot | 776 | // change hotspot | ||
850 | pointer->setCursor(cursorSurface, QPoint(6, 6)); | 777 | pointer->setCursor(cursorSurface, QPoint(6, 6)); | ||
851 | m_connection->flush(); | 778 | Test::flushWaylandConnection(); | ||
852 | QTRY_COMPARE(p->cursorHotSpot(), QPoint(6, 6)); | 779 | QTRY_COMPARE(p->cursorHotSpot(), QPoint(6, 6)); | ||
853 | QCOMPARE(p->cursorImage(), red); | 780 | QCOMPARE(p->cursorImage(), red); | ||
854 | 781 | | |||
855 | // change the buffer | 782 | // change the buffer | ||
856 | QImage blue = QImage(QSize(10, 10), QImage::Format_ARGB32); | 783 | QImage blue = QImage(QSize(10, 10), QImage::Format_ARGB32); | ||
857 | blue.fill(Qt::blue); | 784 | blue.fill(Qt::blue); | ||
858 | auto b = m_shm->createBuffer(blue); | 785 | auto b = Test::waylandShmPool()->createBuffer(blue); | ||
859 | cursorSurface->attachBuffer(b); | 786 | cursorSurface->attachBuffer(b); | ||
860 | cursorSurface->damage(QRect(0, 0, 10, 10)); | 787 | cursorSurface->damage(QRect(0, 0, 10, 10)); | ||
861 | cursorSurface->commit(); | 788 | cursorSurface->commit(); | ||
862 | QVERIFY(cursorRenderedSpy.wait()); | 789 | QVERIFY(cursorRenderedSpy.wait()); | ||
863 | QTRY_COMPARE(p->cursorImage(), blue); | 790 | QTRY_COMPARE(p->cursorImage(), blue); | ||
864 | QCOMPARE(p->cursorHotSpot(), QPoint(6, 6)); | 791 | QCOMPARE(p->cursorHotSpot(), QPoint(6, 6)); | ||
865 | 792 | | |||
866 | // hide the cursor | 793 | // hide the cursor | ||
867 | pointer->setCursor(nullptr); | 794 | pointer->setCursor(nullptr); | ||
868 | m_connection->flush(); | 795 | Test::flushWaylandConnection(); | ||
869 | QTRY_VERIFY(p->cursorImage().isNull()); | 796 | QTRY_VERIFY(p->cursorImage().isNull()); | ||
870 | 797 | | |||
871 | // move cursor somewhere else, should reset to fallback cursor | 798 | // move cursor somewhere else, should reset to fallback cursor | ||
872 | Cursor::setPos(window->geometry().bottomLeft() + QPoint(20, 20)); | 799 | Cursor::setPos(window->geometry().bottomLeft() + QPoint(20, 20)); | ||
873 | QVERIFY(p->window().isNull()); | 800 | QVERIFY(p->window().isNull()); | ||
874 | QVERIFY(!p->cursorImage().isNull()); | 801 | QVERIFY(!p->cursorImage().isNull()); | ||
875 | } | 802 | } | ||
876 | 803 | | |||
Show All 22 Lines | 813 | { | |||
899 | auto p = input()->pointer(); | 826 | auto p = input()->pointer(); | ||
900 | // here we should have the fallback cursor | 827 | // here we should have the fallback cursor | ||
901 | const QImage fallback = p->cursorImage(); | 828 | const QImage fallback = p->cursorImage(); | ||
902 | QVERIFY(!fallback.isNull()); | 829 | QVERIFY(!fallback.isNull()); | ||
903 | 830 | | |||
904 | // now let's create a window | 831 | // now let's create a window | ||
905 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 832 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
906 | QVERIFY(clientAddedSpy.isValid()); | 833 | QVERIFY(clientAddedSpy.isValid()); | ||
907 | Surface *surface = m_compositor->createSurface(m_compositor); | 834 | Surface *surface = Test::createSurface(m_compositor); | ||
908 | QVERIFY(surface); | 835 | QVERIFY(surface); | ||
909 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 836 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
910 | QVERIFY(shellSurface); | 837 | QVERIFY(shellSurface); | ||
911 | render(surface); | 838 | render(surface); | ||
912 | QVERIFY(clientAddedSpy.wait()); | 839 | QVERIFY(clientAddedSpy.wait()); | ||
913 | AbstractClient *window = workspace()->activeClient(); | 840 | AbstractClient *window = workspace()->activeClient(); | ||
914 | QVERIFY(window); | 841 | QVERIFY(window); | ||
915 | 842 | | |||
916 | // and move cursor to the window | 843 | // and move cursor to the window | ||
917 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | 844 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |