Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/window_selection_test.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | void TestWindowSelection::init() | 82 | void TestWindowSelection::init() | ||
83 | { | 83 | { | ||
84 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | 84 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | ||
85 | QVERIFY(Test::waitForWaylandPointer()); | 85 | QVERIFY(Test::waitForWaylandPointer()); | ||
86 | 86 | | |||
87 | screens()->setCurrent(0); | 87 | screens()->setCurrent(0); | ||
88 | KWin::Cursor::setPos(QPoint(1280, 512)); | 88 | KWin::Cursors::self()->mouse()->setPos(QPoint(1280, 512)); | ||
89 | } | 89 | } | ||
90 | 90 | | |||
91 | void TestWindowSelection::cleanup() | 91 | void TestWindowSelection::cleanup() | ||
92 | { | 92 | { | ||
93 | Test::destroyWaylandConnection(); | 93 | Test::destroyWaylandConnection(); | ||
94 | } | 94 | } | ||
95 | 95 | | |||
96 | void TestWindowSelection::testSelectOnWindowPointer() | 96 | void TestWindowSelection::testSelectOnWindowPointer() | ||
Show All 10 Lines | 97 | { | |||
107 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 107 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
108 | QVERIFY(keyboardEnteredSpy.isValid()); | 108 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
109 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | 109 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | ||
110 | QVERIFY(keyboardLeftSpy.isValid()); | 110 | QVERIFY(keyboardLeftSpy.isValid()); | ||
111 | 111 | | |||
112 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 112 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
113 | QVERIFY(client); | 113 | QVERIFY(client); | ||
114 | QVERIFY(keyboardEnteredSpy.wait()); | 114 | QVERIFY(keyboardEnteredSpy.wait()); | ||
115 | KWin::Cursor::setPos(client->frameGeometry().center()); | 115 | KWin::Cursors::self()->mouse()->setPos(client->frameGeometry().center()); | ||
116 | QCOMPARE(input()->pointer()->focus().data(), client); | 116 | QCOMPARE(input()->pointer()->focus().data(), client); | ||
117 | QVERIFY(pointerEnteredSpy.wait()); | 117 | QVERIFY(pointerEnteredSpy.wait()); | ||
118 | 118 | | |||
119 | Toplevel *selectedWindow = nullptr; | 119 | Toplevel *selectedWindow = nullptr; | ||
120 | auto callback = [&selectedWindow] (Toplevel *t) { | 120 | auto callback = [&selectedWindow] (Toplevel *t) { | ||
121 | selectedWindow = t; | 121 | selectedWindow = t; | ||
122 | }; | 122 | }; | ||
123 | 123 | | |||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 183 | { | |||
193 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 193 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
194 | QVERIFY(keyboardEnteredSpy.isValid()); | 194 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
195 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | 195 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | ||
196 | QVERIFY(keyboardLeftSpy.isValid()); | 196 | QVERIFY(keyboardLeftSpy.isValid()); | ||
197 | 197 | | |||
198 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 198 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
199 | QVERIFY(client); | 199 | QVERIFY(client); | ||
200 | QVERIFY(keyboardEnteredSpy.wait()); | 200 | QVERIFY(keyboardEnteredSpy.wait()); | ||
201 | QVERIFY(!client->frameGeometry().contains(KWin::Cursor::pos())); | 201 | QVERIFY(!client->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos())); | ||
202 | 202 | | |||
203 | Toplevel *selectedWindow = nullptr; | 203 | Toplevel *selectedWindow = nullptr; | ||
204 | auto callback = [&selectedWindow] (Toplevel *t) { | 204 | auto callback = [&selectedWindow] (Toplevel *t) { | ||
205 | selectedWindow = t; | 205 | selectedWindow = t; | ||
206 | }; | 206 | }; | ||
207 | 207 | | |||
208 | // start the interaction | 208 | // start the interaction | ||
209 | QCOMPARE(input()->isSelectingWindow(), false); | 209 | QCOMPARE(input()->isSelectingWindow(), false); | ||
210 | kwinApp()->platform()->startInteractiveWindowSelection(callback); | 210 | kwinApp()->platform()->startInteractiveWindowSelection(callback); | ||
211 | QCOMPARE(input()->isSelectingWindow(), true); | 211 | QCOMPARE(input()->isSelectingWindow(), true); | ||
212 | QVERIFY(!selectedWindow); | 212 | QVERIFY(!selectedWindow); | ||
213 | QCOMPARE(keyboardLeftSpy.count(), 0); | 213 | QCOMPARE(keyboardLeftSpy.count(), 0); | ||
214 | QVERIFY(keyboardLeftSpy.wait()); | 214 | QVERIFY(keyboardLeftSpy.wait()); | ||
215 | QCOMPARE(pointerLeftSpy.count(), 0); | 215 | QCOMPARE(pointerLeftSpy.count(), 0); | ||
216 | QCOMPARE(keyboardLeftSpy.count(), 1); | 216 | QCOMPARE(keyboardLeftSpy.count(), 1); | ||
217 | 217 | | |||
218 | // simulate key press | 218 | // simulate key press | ||
219 | quint32 timestamp = 0; | 219 | quint32 timestamp = 0; | ||
220 | // move cursor through keys | 220 | // move cursor through keys | ||
221 | auto keyPress = [×tamp] (qint32 key) { | 221 | auto keyPress = [×tamp] (qint32 key) { | ||
222 | kwinApp()->platform()->keyboardKeyPressed(key, timestamp++); | 222 | kwinApp()->platform()->keyboardKeyPressed(key, timestamp++); | ||
223 | kwinApp()->platform()->keyboardKeyReleased(key, timestamp++); | 223 | kwinApp()->platform()->keyboardKeyReleased(key, timestamp++); | ||
224 | }; | 224 | }; | ||
225 | while (KWin::Cursor::pos().x() >= client->frameGeometry().x() + client->frameGeometry().width()) { | 225 | while (KWin::Cursors::self()->mouse()->pos().x() >= client->frameGeometry().x() + client->frameGeometry().width()) { | ||
226 | keyPress(KEY_LEFT); | 226 | keyPress(KEY_LEFT); | ||
227 | } | 227 | } | ||
228 | while (KWin::Cursor::pos().x() <= client->frameGeometry().x()) { | 228 | while (KWin::Cursors::self()->mouse()->pos().x() <= client->frameGeometry().x()) { | ||
229 | keyPress(KEY_RIGHT); | 229 | keyPress(KEY_RIGHT); | ||
230 | } | 230 | } | ||
231 | while (KWin::Cursor::pos().y() <= client->frameGeometry().y()) { | 231 | while (KWin::Cursors::self()->mouse()->pos().y() <= client->frameGeometry().y()) { | ||
232 | keyPress(KEY_DOWN); | 232 | keyPress(KEY_DOWN); | ||
233 | } | 233 | } | ||
234 | while (KWin::Cursor::pos().y() >= client->frameGeometry().y() + client->frameGeometry().height()) { | 234 | while (KWin::Cursors::self()->mouse()->pos().y() >= client->frameGeometry().y() + client->frameGeometry().height()) { | ||
235 | keyPress(KEY_UP); | 235 | keyPress(KEY_UP); | ||
236 | } | 236 | } | ||
237 | QFETCH(qint32, key); | 237 | QFETCH(qint32, key); | ||
238 | kwinApp()->platform()->keyboardKeyPressed(key, timestamp++); | 238 | kwinApp()->platform()->keyboardKeyPressed(key, timestamp++); | ||
239 | QCOMPARE(input()->isSelectingWindow(), false); | 239 | QCOMPARE(input()->isSelectingWindow(), false); | ||
240 | QCOMPARE(selectedWindow, client); | 240 | QCOMPARE(selectedWindow, client); | ||
241 | QCOMPARE(input()->pointer()->focus().data(), client); | 241 | QCOMPARE(input()->pointer()->focus().data(), client); | ||
242 | // should give back keyboard and pointer | 242 | // should give back keyboard and pointer | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 318 | { | |||
328 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 328 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
329 | QVERIFY(keyboardEnteredSpy.isValid()); | 329 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
330 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | 330 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | ||
331 | QVERIFY(keyboardLeftSpy.isValid()); | 331 | QVERIFY(keyboardLeftSpy.isValid()); | ||
332 | 332 | | |||
333 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 333 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
334 | QVERIFY(client); | 334 | QVERIFY(client); | ||
335 | QVERIFY(keyboardEnteredSpy.wait()); | 335 | QVERIFY(keyboardEnteredSpy.wait()); | ||
336 | KWin::Cursor::setPos(client->frameGeometry().center()); | 336 | KWin::Cursors::self()->mouse()->setPos(client->frameGeometry().center()); | ||
337 | QCOMPARE(input()->pointer()->focus().data(), client); | 337 | QCOMPARE(input()->pointer()->focus().data(), client); | ||
338 | QVERIFY(pointerEnteredSpy.wait()); | 338 | QVERIFY(pointerEnteredSpy.wait()); | ||
339 | 339 | | |||
340 | Toplevel *selectedWindow = nullptr; | 340 | Toplevel *selectedWindow = nullptr; | ||
341 | auto callback = [&selectedWindow] (Toplevel *t) { | 341 | auto callback = [&selectedWindow] (Toplevel *t) { | ||
342 | selectedWindow = t; | 342 | selectedWindow = t; | ||
343 | }; | 343 | }; | ||
344 | 344 | | |||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 377 | { | |||
387 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 387 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
388 | QVERIFY(keyboardEnteredSpy.isValid()); | 388 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
389 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | 389 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | ||
390 | QVERIFY(keyboardLeftSpy.isValid()); | 390 | QVERIFY(keyboardLeftSpy.isValid()); | ||
391 | 391 | | |||
392 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 392 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
393 | QVERIFY(client); | 393 | QVERIFY(client); | ||
394 | QVERIFY(keyboardEnteredSpy.wait()); | 394 | QVERIFY(keyboardEnteredSpy.wait()); | ||
395 | KWin::Cursor::setPos(client->frameGeometry().center()); | 395 | KWin::Cursors::self()->mouse()->setPos(client->frameGeometry().center()); | ||
396 | QCOMPARE(input()->pointer()->focus().data(), client); | 396 | QCOMPARE(input()->pointer()->focus().data(), client); | ||
397 | QVERIFY(pointerEnteredSpy.wait()); | 397 | QVERIFY(pointerEnteredSpy.wait()); | ||
398 | 398 | | |||
399 | Toplevel *selectedWindow = nullptr; | 399 | Toplevel *selectedWindow = nullptr; | ||
400 | auto callback = [&selectedWindow] (Toplevel *t) { | 400 | auto callback = [&selectedWindow] (Toplevel *t) { | ||
401 | selectedWindow = t; | 401 | selectedWindow = t; | ||
402 | }; | 402 | }; | ||
403 | 403 | | |||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 436 | { | |||
446 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | 446 | QSignalSpy keyboardEnteredSpy(keyboard.data(), &Keyboard::entered); | ||
447 | QVERIFY(keyboardEnteredSpy.isValid()); | 447 | QVERIFY(keyboardEnteredSpy.isValid()); | ||
448 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | 448 | QSignalSpy keyboardLeftSpy(keyboard.data(), &Keyboard::left); | ||
449 | QVERIFY(keyboardLeftSpy.isValid()); | 449 | QVERIFY(keyboardLeftSpy.isValid()); | ||
450 | 450 | | |||
451 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 451 | auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
452 | QVERIFY(client); | 452 | QVERIFY(client); | ||
453 | QVERIFY(keyboardEnteredSpy.wait()); | 453 | QVERIFY(keyboardEnteredSpy.wait()); | ||
454 | KWin::Cursor::setPos(client->frameGeometry().center()); | 454 | KWin::Cursors::self()->mouse()->setPos(client->frameGeometry().center()); | ||
455 | QCOMPARE(input()->pointer()->focus().data(), client); | 455 | QCOMPARE(input()->pointer()->focus().data(), client); | ||
456 | QVERIFY(pointerEnteredSpy.wait()); | 456 | QVERIFY(pointerEnteredSpy.wait()); | ||
457 | 457 | | |||
458 | QPoint point; | 458 | QPoint point; | ||
459 | auto callback = [&point] (const QPoint &p) { | 459 | auto callback = [&point] (const QPoint &p) { | ||
460 | point = p; | 460 | point = p; | ||
461 | }; | 461 | }; | ||
462 | 462 | | |||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |