Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
| Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 56 | private Q_SLOTS: | |||
|---|---|---|---|---|---|
| 58 | void init(); | 58 | void init(); | ||
| 59 | void cleanup(); | 59 | void cleanup(); | ||
| 60 | void testWarpingUpdatesFocus(); | 60 | void testWarpingUpdatesFocus(); | ||
| 61 | void testWarpingGeneratesPointerMotion(); | 61 | void testWarpingGeneratesPointerMotion(); | ||
| 62 | void testWarpingDuringFilter(); | 62 | void testWarpingDuringFilter(); | ||
| 63 | void testUpdateFocusAfterScreenChange(); | 63 | void testUpdateFocusAfterScreenChange(); | ||
| 64 | void testModifierClickUnrestrictedMove_data(); | 64 | void testModifierClickUnrestrictedMove_data(); | ||
| 65 | void testModifierClickUnrestrictedMove(); | 65 | void testModifierClickUnrestrictedMove(); | ||
| 66 | void testModifierClickUnrestrictedMoveGlobalShortcutsDisabled(); | ||||
| 66 | void testModifierScrollOpacity_data(); | 67 | void testModifierScrollOpacity_data(); | ||
| 67 | void testModifierScrollOpacity(); | 68 | void testModifierScrollOpacity(); | ||
| 69 | void testModifierScrollOpacityGlobalShortcutsDisabled(); | ||||
| 68 | void testScrollAction(); | 70 | void testScrollAction(); | ||
| 69 | void testFocusFollowsMouse(); | 71 | void testFocusFollowsMouse(); | ||
| 70 | void testMouseActionInactiveWindow_data(); | 72 | void testMouseActionInactiveWindow_data(); | ||
| 71 | void testMouseActionInactiveWindow(); | 73 | void testMouseActionInactiveWindow(); | ||
| 72 | void testMouseActionActiveWindow_data(); | 74 | void testMouseActionActiveWindow_data(); | ||
| 73 | void testMouseActionActiveWindow(); | 75 | void testMouseActionActiveWindow(); | ||
| 74 | void testCursorImage(); | 76 | void testCursorImage(); | ||
| 75 | void testEffectOverrideCursorImage(); | 77 | void testEffectOverrideCursorImage(); | ||
| ▲ Show 20 Lines • Show All 343 Lines • ▼ Show 20 Line(s) | 362 | { | |||
| 419 | } | 421 | } | ||
| 420 | 422 | | |||
| 421 | // all of that should not have triggered button events on the surface | 423 | // all of that should not have triggered button events on the surface | ||
| 422 | QCOMPARE(buttonSpy.count(), 0); | 424 | QCOMPARE(buttonSpy.count(), 0); | ||
| 423 | // also waiting shouldn't give us the event | 425 | // also waiting shouldn't give us the event | ||
| 424 | QVERIFY(!buttonSpy.wait(100)); | 426 | QVERIFY(!buttonSpy.wait(100)); | ||
| 425 | } | 427 | } | ||
| 426 | 428 | | |||
| 429 | void PointerInputTest::testModifierClickUnrestrictedMoveGlobalShortcutsDisabled() | ||||
| 430 | { | ||||
| 431 | // this test ensures that Alt+mouse button press triggers unrestricted move | ||||
| 432 | using namespace KWayland::Client; | ||||
| 433 | // create pointer and signal spy for button events | ||||
| 434 | auto pointer = m_seat->createPointer(m_seat); | ||||
| 435 | QVERIFY(pointer); | ||||
| 436 | QVERIFY(pointer->isValid()); | ||||
| 437 | QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); | ||||
| 438 | QVERIFY(buttonSpy.isValid()); | ||||
| 439 | | ||||
| 440 | // first modify the config for this run | ||||
| 441 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
| 442 | group.writeEntry("CommandAllKey", "Alt"); | ||||
| 443 | group.writeEntry("CommandAll1", "Move"); | ||||
| 444 | group.writeEntry("CommandAll2", "Move"); | ||||
| 445 | group.writeEntry("CommandAll3", "Move"); | ||||
| 446 | group.sync(); | ||||
| 447 | workspace()->slotReconfigure(); | ||||
| 448 | QCOMPARE(options->commandAllModifier(), Qt::AltModifier); | ||||
| 449 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||||
| 450 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||||
| 451 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||||
| 452 | | ||||
| 453 | // create a window | ||||
| 454 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
| 455 | QVERIFY(clientAddedSpy.isValid()); | ||||
| 456 | Surface *surface = Test::createSurface(m_compositor); | ||||
| 457 | QVERIFY(surface); | ||||
| 458 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||||
| 459 | QVERIFY(shellSurface); | ||||
| 460 | render(surface); | ||||
| 461 | QVERIFY(clientAddedSpy.wait()); | ||||
| 462 | AbstractClient *window = workspace()->activeClient(); | ||||
| 463 | QVERIFY(window); | ||||
| 464 | | ||||
| 465 | // disable global shortcuts | ||||
| 466 | QVERIFY(!workspace()->globalShortcutsDisabled()); | ||||
| 467 | workspace()->disableGlobalShortcutsForClient(true); | ||||
| 468 | QVERIFY(workspace()->globalShortcutsDisabled()); | ||||
| 469 | | ||||
| 470 | // move cursor on window | ||||
| 471 | Cursor::setPos(window->geometry().center()); | ||||
| 472 | | ||||
| 473 | // simulate modifier+click | ||||
| 474 | quint32 timestamp = 1; | ||||
| 475 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); | ||||
| 476 | QVERIFY(!window->isMove()); | ||||
| 477 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||||
| 478 | QVERIFY(!window->isMove()); | ||||
| 479 | // release modifier should not change it | ||||
| 480 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||||
| 481 | QVERIFY(!window->isMove()); | ||||
| 482 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||||
| 483 | | ||||
| 484 | workspace()->disableGlobalShortcutsForClient(false); | ||||
| 485 | } | ||||
| 486 | | ||||
| 427 | void PointerInputTest::testModifierScrollOpacity_data() | 487 | void PointerInputTest::testModifierScrollOpacity_data() | ||
| 428 | { | 488 | { | ||
| 429 | QTest::addColumn<int>("modifierKey"); | 489 | QTest::addColumn<int>("modifierKey"); | ||
| 430 | QTest::addColumn<QString>("modKey"); | 490 | QTest::addColumn<QString>("modKey"); | ||
| 431 | QTest::addColumn<bool>("capsLock"); | 491 | QTest::addColumn<bool>("capsLock"); | ||
| 432 | 492 | | |||
| 433 | const QString alt = QStringLiteral("Alt"); | 493 | const QString alt = QStringLiteral("Alt"); | ||
| 434 | const QString meta = QStringLiteral("Meta"); | 494 | const QString meta = QStringLiteral("Meta"); | ||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 557 | if (capsLock) { | |||
| 498 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | 558 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||
| 499 | } | 559 | } | ||
| 500 | 560 | | |||
| 501 | // axis should have been filtered out | 561 | // axis should have been filtered out | ||
| 502 | QCOMPARE(axisSpy.count(), 0); | 562 | QCOMPARE(axisSpy.count(), 0); | ||
| 503 | QVERIFY(!axisSpy.wait(100)); | 563 | QVERIFY(!axisSpy.wait(100)); | ||
| 504 | } | 564 | } | ||
| 505 | 565 | | |||
| 566 | void PointerInputTest::testModifierScrollOpacityGlobalShortcutsDisabled() | ||||
| 567 | { | ||||
| 568 | // this test verifies that mod+wheel performs a window operation and does not | ||||
| 569 | // pass the wheel to the window | ||||
| 570 | using namespace KWayland::Client; | ||||
| 571 | // create pointer and signal spy for button events | ||||
| 572 | auto pointer = m_seat->createPointer(m_seat); | ||||
| 573 | QVERIFY(pointer); | ||||
| 574 | QVERIFY(pointer->isValid()); | ||||
| 575 | QSignalSpy axisSpy(pointer, &Pointer::axisChanged); | ||||
| 576 | QVERIFY(axisSpy.isValid()); | ||||
| 577 | | ||||
| 578 | // first modify the config for this run | ||||
| 579 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
| 580 | group.writeEntry("CommandAllKey", "Alt"); | ||||
| 581 | group.writeEntry("CommandAllWheel", "change opacity"); | ||||
| 582 | group.sync(); | ||||
| 583 | workspace()->slotReconfigure(); | ||||
| 584 | | ||||
| 585 | // create a window | ||||
| 586 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
| 587 | QVERIFY(clientAddedSpy.isValid()); | ||||
| 588 | Surface *surface = Test::createSurface(m_compositor); | ||||
| 589 | QVERIFY(surface); | ||||
| 590 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||||
| 591 | QVERIFY(shellSurface); | ||||
| 592 | render(surface); | ||||
| 593 | QVERIFY(clientAddedSpy.wait()); | ||||
| 594 | AbstractClient *window = workspace()->activeClient(); | ||||
| 595 | QVERIFY(window); | ||||
| 596 | // set the opacity to 0.5 | ||||
| 597 | window->setOpacity(0.5); | ||||
| 598 | QCOMPARE(window->opacity(), 0.5); | ||||
| 599 | | ||||
| 600 | // move cursor on window | ||||
| 601 | Cursor::setPos(window->geometry().center()); | ||||
| 602 | | ||||
| 603 | // disable global shortcuts | ||||
| 604 | QVERIFY(!workspace()->globalShortcutsDisabled()); | ||||
| 605 | workspace()->disableGlobalShortcutsForClient(true); | ||||
| 606 | QVERIFY(workspace()->globalShortcutsDisabled()); | ||||
| 607 | | ||||
| 608 | // simulate modifier+wheel | ||||
| 609 | quint32 timestamp = 1; | ||||
| 610 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); | ||||
| 611 | kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); | ||||
| 612 | QCOMPARE(window->opacity(), 0.5); | ||||
| 613 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | ||||
| 614 | QCOMPARE(window->opacity(), 0.5); | ||||
| 615 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||||
| 616 | | ||||
| 617 | workspace()->disableGlobalShortcutsForClient(false); | ||||
| 618 | } | ||||
| 619 | | ||||
| 506 | void PointerInputTest::testScrollAction() | 620 | void PointerInputTest::testScrollAction() | ||
| 507 | { | 621 | { | ||
| 508 | // this test verifies that scroll on inactive window performs a mouse action | 622 | // this test verifies that scroll on inactive window performs a mouse action | ||
| 509 | using namespace KWayland::Client; | 623 | using namespace KWayland::Client; | ||
| 510 | auto pointer = m_seat->createPointer(m_seat); | 624 | auto pointer = m_seat->createPointer(m_seat); | ||
| 511 | QVERIFY(pointer); | 625 | QVERIFY(pointer); | ||
| 512 | QVERIFY(pointer->isValid()); | 626 | QVERIFY(pointer->isValid()); | ||
| 513 | QSignalSpy axisSpy(pointer, &Pointer::axisChanged); | 627 | QSignalSpy axisSpy(pointer, &Pointer::axisChanged); | ||
| ▲ Show 20 Lines • Show All 791 Lines • Show Last 20 Lines | |||||