Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Line(s) | 215 | { | |||
---|---|---|---|---|---|
257 | QCOMPARE(enteredSpy.count(), 1); | 257 | QCOMPARE(enteredSpy.count(), 1); | ||
258 | } | 258 | } | ||
259 | 259 | | |||
260 | void PointerInputTest::testModifierClickUnrestrictedMove_data() | 260 | void PointerInputTest::testModifierClickUnrestrictedMove_data() | ||
261 | { | 261 | { | ||
262 | QTest::addColumn<int>("modifierKey"); | 262 | QTest::addColumn<int>("modifierKey"); | ||
263 | QTest::addColumn<int>("mouseButton"); | 263 | QTest::addColumn<int>("mouseButton"); | ||
264 | QTest::addColumn<QString>("modKey"); | 264 | QTest::addColumn<QString>("modKey"); | ||
265 | QTest::addColumn<bool>("capsLock"); | ||||
265 | 266 | | |||
266 | const QString alt = QStringLiteral("Alt"); | 267 | const QString alt = QStringLiteral("Alt"); | ||
267 | const QString meta = QStringLiteral("Meta"); | 268 | const QString meta = QStringLiteral("Meta"); | ||
268 | 269 | | |||
269 | QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt; | 270 | QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false; | ||
270 | QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt; | 271 | QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false; | ||
271 | QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt; | 272 | QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false; | ||
272 | QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt; | 273 | QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false; | ||
273 | QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt; | 274 | QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false; | ||
274 | QTest::newRow("Right Alt + Middle Click") << KEY_RIGHTALT << BTN_MIDDLE << alt; | 275 | QTest::newRow("Right Alt + Middle Click") << KEY_RIGHTALT << BTN_MIDDLE << alt << false; | ||
275 | // now everything with meta | 276 | // now everything with meta | ||
276 | QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta; | 277 | QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false; | ||
277 | QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta; | 278 | QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false; | ||
278 | QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta; | 279 | QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false; | ||
279 | QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta; | 280 | QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false; | ||
280 | QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta; | 281 | QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false; | ||
281 | QTest::newRow("Right Meta + Middle Click") << KEY_RIGHTMETA << BTN_MIDDLE << meta; | 282 | QTest::newRow("Right Meta + Middle Click") << KEY_RIGHTMETA << BTN_MIDDLE << meta << false; | ||
283 | | ||||
284 | // and with capslock | ||||
285 | QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true; | ||||
286 | QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true; | ||||
287 | QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true; | ||||
288 | QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true; | ||||
289 | QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true; | ||||
290 | QTest::newRow("Right Alt + Middle Click/CapsLock") << KEY_RIGHTALT << BTN_MIDDLE << alt << true; | ||||
291 | // now everything with meta | ||||
292 | QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true; | ||||
293 | QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true; | ||||
294 | QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true; | ||||
295 | QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true; | ||||
296 | QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true; | ||||
297 | QTest::newRow("Right Meta + Middle Click/CapsLock") << KEY_RIGHTMETA << BTN_MIDDLE << meta << true; | ||||
282 | } | 298 | } | ||
283 | 299 | | |||
284 | void PointerInputTest::testModifierClickUnrestrictedMove() | 300 | void PointerInputTest::testModifierClickUnrestrictedMove() | ||
285 | { | 301 | { | ||
286 | // this test ensures that Alt+mouse button press triggers unrestricted move | 302 | // this test ensures that Alt+mouse button press triggers unrestricted move | ||
287 | using namespace KWayland::Client; | 303 | using namespace KWayland::Client; | ||
288 | // create pointer and signal spy for button events | 304 | // create pointer and signal spy for button events | ||
289 | auto pointer = m_seat->createPointer(m_seat); | 305 | auto pointer = m_seat->createPointer(m_seat); | ||
Show All 28 Lines | |||||
318 | AbstractClient *window = workspace()->activeClient(); | 334 | AbstractClient *window = workspace()->activeClient(); | ||
319 | QVERIFY(window); | 335 | QVERIFY(window); | ||
320 | 336 | | |||
321 | // move cursor on window | 337 | // move cursor on window | ||
322 | Cursor::setPos(window->geometry().center()); | 338 | Cursor::setPos(window->geometry().center()); | ||
323 | 339 | | |||
324 | // simulate modifier+click | 340 | // simulate modifier+click | ||
325 | quint32 timestamp = 1; | 341 | quint32 timestamp = 1; | ||
342 | QFETCH(bool, capsLock); | ||||
343 | if (capsLock) { | ||||
344 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | ||||
345 | } | ||||
326 | QFETCH(int, modifierKey); | 346 | QFETCH(int, modifierKey); | ||
327 | QFETCH(int, mouseButton); | 347 | QFETCH(int, mouseButton); | ||
328 | kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); | 348 | kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); | ||
329 | QVERIFY(!window->isMove()); | 349 | QVERIFY(!window->isMove()); | ||
330 | kwinApp()->platform()->pointerButtonPressed(mouseButton, timestamp++); | 350 | kwinApp()->platform()->pointerButtonPressed(mouseButton, timestamp++); | ||
331 | QVERIFY(window->isMove()); | 351 | QVERIFY(window->isMove()); | ||
332 | // release modifier should not change it | 352 | // release modifier should not change it | ||
333 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | 353 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | ||
334 | QVERIFY(window->isMove()); | 354 | QVERIFY(window->isMove()); | ||
335 | // but releasing the key should end move/resize | 355 | // but releasing the key should end move/resize | ||
336 | kwinApp()->platform()->pointerButtonReleased(mouseButton, timestamp++); | 356 | kwinApp()->platform()->pointerButtonReleased(mouseButton, timestamp++); | ||
337 | QVERIFY(!window->isMove()); | 357 | QVERIFY(!window->isMove()); | ||
358 | if (capsLock) { | ||||
359 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||||
360 | } | ||||
338 | 361 | | |||
339 | // all of that should not have triggered button events on the surface | 362 | // all of that should not have triggered button events on the surface | ||
340 | QCOMPARE(buttonSpy.count(), 0); | 363 | QCOMPARE(buttonSpy.count(), 0); | ||
341 | // also waiting shouldn't give us the event | 364 | // also waiting shouldn't give us the event | ||
342 | QVERIFY(!buttonSpy.wait(100)); | 365 | QVERIFY(!buttonSpy.wait(100)); | ||
343 | } | 366 | } | ||
344 | 367 | | |||
345 | void PointerInputTest::testModifierScrollOpacity_data() | 368 | void PointerInputTest::testModifierScrollOpacity_data() | ||
346 | { | 369 | { | ||
347 | QTest::addColumn<int>("modifierKey"); | 370 | QTest::addColumn<int>("modifierKey"); | ||
348 | QTest::addColumn<QString>("modKey"); | 371 | QTest::addColumn<QString>("modKey"); | ||
372 | QTest::addColumn<bool>("capsLock"); | ||||
349 | 373 | | |||
350 | const QString alt = QStringLiteral("Alt"); | 374 | const QString alt = QStringLiteral("Alt"); | ||
351 | const QString meta = QStringLiteral("Meta"); | 375 | const QString meta = QStringLiteral("Meta"); | ||
352 | 376 | | |||
353 | QTest::newRow("Left Alt") << KEY_LEFTALT << alt; | 377 | QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false; | ||
354 | QTest::newRow("Right Alt") << KEY_RIGHTALT << alt; | 378 | QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false; | ||
355 | QTest::newRow("Left Meta") << KEY_LEFTMETA << meta; | 379 | QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false; | ||
356 | QTest::newRow("Right Meta") << KEY_RIGHTMETA << meta; | 380 | QTest::newRow("Right Meta") << KEY_RIGHTMETA << meta << false; | ||
381 | QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true; | ||||
382 | QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true; | ||||
383 | QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true; | ||||
384 | QTest::newRow("Right Meta/CapsLock") << KEY_RIGHTMETA << meta << true; | ||||
357 | } | 385 | } | ||
358 | 386 | | |||
359 | void PointerInputTest::testModifierScrollOpacity() | 387 | void PointerInputTest::testModifierScrollOpacity() | ||
360 | { | 388 | { | ||
361 | // this test verifies that mod+wheel performs a window operation and does not | 389 | // this test verifies that mod+wheel performs a window operation and does not | ||
362 | // pass the wheel to the window | 390 | // pass the wheel to the window | ||
363 | using namespace KWayland::Client; | 391 | using namespace KWayland::Client; | ||
364 | // create pointer and signal spy for button events | 392 | // create pointer and signal spy for button events | ||
Show All 26 Lines | |||||
391 | window->setOpacity(0.5); | 419 | window->setOpacity(0.5); | ||
392 | QCOMPARE(window->opacity(), 0.5); | 420 | QCOMPARE(window->opacity(), 0.5); | ||
393 | 421 | | |||
394 | // move cursor on window | 422 | // move cursor on window | ||
395 | Cursor::setPos(window->geometry().center()); | 423 | Cursor::setPos(window->geometry().center()); | ||
396 | 424 | | |||
397 | // simulate modifier+wheel | 425 | // simulate modifier+wheel | ||
398 | quint32 timestamp = 1; | 426 | quint32 timestamp = 1; | ||
427 | QFETCH(bool, capsLock); | ||||
428 | if (capsLock) { | ||||
429 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | ||||
430 | } | ||||
399 | QFETCH(int, modifierKey); | 431 | QFETCH(int, modifierKey); | ||
400 | kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); | 432 | kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); | ||
401 | kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); | 433 | kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); | ||
402 | QCOMPARE(window->opacity(), 0.6); | 434 | QCOMPARE(window->opacity(), 0.6); | ||
403 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | 435 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | ||
404 | QCOMPARE(window->opacity(), 0.5); | 436 | QCOMPARE(window->opacity(), 0.5); | ||
405 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | 437 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | ||
438 | if (capsLock) { | ||||
439 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||||
440 | } | ||||
406 | 441 | | |||
407 | // axis should have been filtered out | 442 | // axis should have been filtered out | ||
408 | QCOMPARE(axisSpy.count(), 0); | 443 | QCOMPARE(axisSpy.count(), 0); | ||
409 | QVERIFY(!axisSpy.wait(100)); | 444 | QVERIFY(!axisSpy.wait(100)); | ||
410 | } | 445 | } | ||
411 | 446 | | |||
412 | void PointerInputTest::testScrollAction() | 447 | void PointerInputTest::testScrollAction() | ||
413 | { | 448 | { | ||
▲ Show 20 Lines • Show All 476 Lines • Show Last 20 Lines |