Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/decoration_input_test.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 57 | private Q_SLOTS: | |||
---|---|---|---|---|---|
67 | void testHover_data(); | 67 | void testHover_data(); | ||
68 | void testHover(); | 68 | void testHover(); | ||
69 | void testPressToMove_data(); | 69 | void testPressToMove_data(); | ||
70 | void testPressToMove(); | 70 | void testPressToMove(); | ||
71 | void testTapToMove_data(); | 71 | void testTapToMove_data(); | ||
72 | void testTapToMove(); | 72 | void testTapToMove(); | ||
73 | void testResizeOutsideWindow_data(); | 73 | void testResizeOutsideWindow_data(); | ||
74 | void testResizeOutsideWindow(); | 74 | void testResizeOutsideWindow(); | ||
75 | void testModifierClickUnrestrictedMove_data(); | ||||
76 | void testModifierClickUnrestrictedMove(); | ||||
77 | void testModifierScrollOpacity_data(); | ||||
78 | void testModifierScrollOpacity(); | ||||
75 | 79 | | |||
76 | private: | 80 | private: | ||
77 | AbstractClient *showWindow(Test::ShellSurfaceType type); | 81 | AbstractClient *showWindow(Test::ShellSurfaceType type); | ||
78 | }; | 82 | }; | ||
79 | 83 | | |||
80 | #define MOTION(target) \ | 84 | #define MOTION(target) \ | ||
81 | kwinApp()->platform()->pointerMotion(target, timestamp++) | 85 | kwinApp()->platform()->pointerMotion(target, timestamp++) | ||
82 | 86 | | |||
▲ Show 20 Lines • Show All 475 Lines • ▼ Show 20 Line(s) | 522 | { | |||
558 | QVERIFY(!c->isResize()); | 562 | QVERIFY(!c->isResize()); | ||
559 | QVERIFY(startMoveResizedSpy.wait()); | 563 | QVERIFY(startMoveResizedSpy.wait()); | ||
560 | QVERIFY(c->isResize()); | 564 | QVERIFY(c->isResize()); | ||
561 | 565 | | |||
562 | RELEASE; | 566 | RELEASE; | ||
563 | QVERIFY(!c->isResize()); | 567 | QVERIFY(!c->isResize()); | ||
564 | } | 568 | } | ||
565 | 569 | | |||
570 | void DecorationInputTest::testModifierClickUnrestrictedMove_data() | ||||
571 | { | ||||
572 | QTest::addColumn<int>("modifierKey"); | ||||
573 | QTest::addColumn<int>("mouseButton"); | ||||
574 | QTest::addColumn<QString>("modKey"); | ||||
575 | QTest::addColumn<bool>("capsLock"); | ||||
576 | QTest::addColumn<Test::ShellSurfaceType>("surfaceType"); | ||||
577 | | ||||
578 | const QString alt = QStringLiteral("Alt"); | ||||
579 | const QString meta = QStringLiteral("Meta"); | ||||
580 | | ||||
581 | const QVector<std::pair<Test::ShellSurfaceType, QByteArray>> surfaceTypes{ | ||||
582 | {Test::ShellSurfaceType::WlShell, QByteArrayLiteral("WlShell")}, | ||||
583 | {Test::ShellSurfaceType::XdgShellV5, QByteArrayLiteral("XdgShellV5")}, | ||||
584 | {Test::ShellSurfaceType::XdgShellV6, QByteArrayLiteral("XdgShellV6")}, | ||||
585 | }; | ||||
586 | | ||||
587 | for (const auto &type: surfaceTypes) { | ||||
588 | QTest::newRow("Left Alt + Left Click" + type.second) << KEY_LEFTALT << BTN_LEFT << alt << false << type.first; | ||||
589 | QTest::newRow("Left Alt + Right Click" + type.second) << KEY_LEFTALT << BTN_RIGHT << alt << false << type.first; | ||||
590 | QTest::newRow("Left Alt + Middle Click" + type.second) << KEY_LEFTALT << BTN_MIDDLE << alt << false << type.first; | ||||
591 | QTest::newRow("Right Alt + Left Click" + type.second) << KEY_RIGHTALT << BTN_LEFT << alt << false << type.first; | ||||
592 | QTest::newRow("Right Alt + Right Click" + type.second) << KEY_RIGHTALT << BTN_RIGHT << alt << false << type.first; | ||||
593 | QTest::newRow("Right Alt + Middle Click" + type.second) << KEY_RIGHTALT << BTN_MIDDLE << alt << false << type.first; | ||||
594 | // now everything with meta | ||||
595 | QTest::newRow("Left Meta + Left Click" + type.second) << KEY_LEFTMETA << BTN_LEFT << meta << false << type.first; | ||||
596 | QTest::newRow("Left Meta + Right Click" + type.second) << KEY_LEFTMETA << BTN_RIGHT << meta << false << type.first; | ||||
597 | QTest::newRow("Left Meta + Middle Click" + type.second) << KEY_LEFTMETA << BTN_MIDDLE << meta << false << type.first; | ||||
598 | QTest::newRow("Right Meta + Left Click" + type.second) << KEY_RIGHTMETA << BTN_LEFT << meta << false << type.first; | ||||
599 | QTest::newRow("Right Meta + Right Click" + type.second) << KEY_RIGHTMETA << BTN_RIGHT << meta << false << type.first; | ||||
600 | QTest::newRow("Right Meta + Middle Click" + type.second) << KEY_RIGHTMETA << BTN_MIDDLE << meta << false << type.first; | ||||
601 | | ||||
602 | // and with capslock | ||||
603 | QTest::newRow("Left Alt + Left Click/CapsLock" + type.second) << KEY_LEFTALT << BTN_LEFT << alt << true << type.first; | ||||
604 | QTest::newRow("Left Alt + Right Click/CapsLock" + type.second) << KEY_LEFTALT << BTN_RIGHT << alt << true << type.first; | ||||
605 | QTest::newRow("Left Alt + Middle Click/CapsLock" + type.second) << KEY_LEFTALT << BTN_MIDDLE << alt << true << type.first; | ||||
606 | QTest::newRow("Right Alt + Left Click/CapsLock" + type.second) << KEY_RIGHTALT << BTN_LEFT << alt << true << type.first; | ||||
607 | QTest::newRow("Right Alt + Right Click/CapsLock" + type.second) << KEY_RIGHTALT << BTN_RIGHT << alt << true << type.first; | ||||
608 | QTest::newRow("Right Alt + Middle Click/CapsLock" + type.second) << KEY_RIGHTALT << BTN_MIDDLE << alt << true << type.first; | ||||
609 | // now everything with meta | ||||
610 | QTest::newRow("Left Meta + Left Click/CapsLock" + type.second) << KEY_LEFTMETA << BTN_LEFT << meta << true << type.first; | ||||
611 | QTest::newRow("Left Meta + Right Click/CapsLock" + type.second) << KEY_LEFTMETA << BTN_RIGHT << meta << true << type.first; | ||||
612 | QTest::newRow("Left Meta + Middle Click/CapsLock" + type.second) << KEY_LEFTMETA << BTN_MIDDLE << meta << true << type.first; | ||||
613 | QTest::newRow("Right Meta + Left Click/CapsLock" + type.second) << KEY_RIGHTMETA << BTN_LEFT << meta << true << type.first; | ||||
614 | QTest::newRow("Right Meta + Right Click/CapsLock" + type.second) << KEY_RIGHTMETA << BTN_RIGHT << meta << true << type.first; | ||||
615 | QTest::newRow("Right Meta + Middle Click/CapsLock" + type.second) << KEY_RIGHTMETA << BTN_MIDDLE << meta << true << type.first; | ||||
616 | } | ||||
617 | } | ||||
618 | | ||||
619 | void DecorationInputTest::testModifierClickUnrestrictedMove() | ||||
620 | { | ||||
621 | // this test ensures that Alt+mouse button press triggers unrestricted move | ||||
622 | | ||||
623 | // first modify the config for this run | ||||
624 | QFETCH(QString, modKey); | ||||
625 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
626 | group.writeEntry("CommandAllKey", modKey); | ||||
627 | group.writeEntry("CommandAll1", "Move"); | ||||
628 | group.writeEntry("CommandAll2", "Move"); | ||||
629 | group.writeEntry("CommandAll3", "Move"); | ||||
630 | group.sync(); | ||||
631 | workspace()->slotReconfigure(); | ||||
632 | QCOMPARE(options->commandAllModifier(), modKey == QStringLiteral("Alt") ? Qt::AltModifier : Qt::MetaModifier); | ||||
633 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||||
634 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||||
635 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||||
636 | | ||||
637 | // create a window | ||||
638 | QFETCH(Test::ShellSurfaceType, surfaceType); | ||||
639 | AbstractClient *c = showWindow(surfaceType); | ||||
640 | QVERIFY(c); | ||||
641 | QVERIFY(c->isDecorated()); | ||||
642 | QVERIFY(!c->noBorder()); | ||||
643 | c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); | ||||
644 | // move cursor on window | ||||
645 | Cursor::setPos(QPoint(c->geometry().center().x(), c->y() + c->clientPos().y() / 2)); | ||||
646 | | ||||
647 | // simulate modifier+click | ||||
648 | quint32 timestamp = 1; | ||||
649 | QFETCH(bool, capsLock); | ||||
650 | if (capsLock) { | ||||
651 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | ||||
652 | } | ||||
653 | QFETCH(int, modifierKey); | ||||
654 | QFETCH(int, mouseButton); | ||||
655 | kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); | ||||
656 | QVERIFY(!c->isMove()); | ||||
657 | kwinApp()->platform()->pointerButtonPressed(mouseButton, timestamp++); | ||||
658 | QVERIFY(c->isMove()); | ||||
659 | // release modifier should not change it | ||||
660 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | ||||
661 | QVERIFY(c->isMove()); | ||||
662 | // but releasing the key should end move/resize | ||||
663 | kwinApp()->platform()->pointerButtonReleased(mouseButton, timestamp++); | ||||
664 | QVERIFY(!c->isMove()); | ||||
665 | if (capsLock) { | ||||
666 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||||
667 | } | ||||
668 | } | ||||
669 | | ||||
670 | void DecorationInputTest::testModifierScrollOpacity_data() | ||||
671 | { | ||||
672 | QTest::addColumn<int>("modifierKey"); | ||||
673 | QTest::addColumn<QString>("modKey"); | ||||
674 | QTest::addColumn<bool>("capsLock"); | ||||
675 | QTest::addColumn<Test::ShellSurfaceType>("surfaceType"); | ||||
676 | | ||||
677 | const QString alt = QStringLiteral("Alt"); | ||||
678 | const QString meta = QStringLiteral("Meta"); | ||||
679 | | ||||
680 | const QVector<std::pair<Test::ShellSurfaceType, QByteArray>> surfaceTypes{ | ||||
681 | {Test::ShellSurfaceType::WlShell, QByteArrayLiteral("WlShell")}, | ||||
682 | {Test::ShellSurfaceType::XdgShellV5, QByteArrayLiteral("XdgShellV5")}, | ||||
683 | {Test::ShellSurfaceType::XdgShellV6, QByteArrayLiteral("XdgShellV6")}, | ||||
684 | }; | ||||
685 | | ||||
686 | for (const auto &type: surfaceTypes) { | ||||
687 | QTest::newRow("Left Alt" + type.second) << KEY_LEFTALT << alt << false << type.first; | ||||
688 | QTest::newRow("Right Alt" + type.second) << KEY_RIGHTALT << alt << false << type.first; | ||||
689 | QTest::newRow("Left Meta" + type.second) << KEY_LEFTMETA << meta << false << type.first; | ||||
690 | QTest::newRow("Right Meta" + type.second) << KEY_RIGHTMETA << meta << false << type.first; | ||||
691 | QTest::newRow("Left Alt/CapsLock" + type.second) << KEY_LEFTALT << alt << true << type.first; | ||||
692 | QTest::newRow("Right Alt/CapsLock" + type.second) << KEY_RIGHTALT << alt << true << type.first; | ||||
693 | QTest::newRow("Left Meta/CapsLock" + type.second) << KEY_LEFTMETA << meta << true << type.first; | ||||
694 | QTest::newRow("Right Meta/CapsLock" + type.second) << KEY_RIGHTMETA << meta << true << type.first; | ||||
695 | } | ||||
696 | } | ||||
697 | | ||||
698 | void DecorationInputTest::testModifierScrollOpacity() | ||||
699 | { | ||||
700 | // this test verifies that mod+wheel performs a window operation | ||||
701 | | ||||
702 | // first modify the config for this run | ||||
703 | QFETCH(QString, modKey); | ||||
704 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
705 | group.writeEntry("CommandAllKey", modKey); | ||||
706 | group.writeEntry("CommandAllWheel", "change opacity"); | ||||
707 | group.sync(); | ||||
708 | workspace()->slotReconfigure(); | ||||
709 | | ||||
710 | QFETCH(Test::ShellSurfaceType, surfaceType); | ||||
711 | AbstractClient *c = showWindow(surfaceType); | ||||
712 | QVERIFY(c); | ||||
713 | QVERIFY(c->isDecorated()); | ||||
714 | QVERIFY(!c->noBorder()); | ||||
715 | c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); | ||||
716 | // move cursor on window | ||||
717 | Cursor::setPos(QPoint(c->geometry().center().x(), c->y() + c->clientPos().y() / 2)); | ||||
718 | // set the opacity to 0.5 | ||||
719 | c->setOpacity(0.5); | ||||
720 | QCOMPARE(c->opacity(), 0.5); | ||||
721 | | ||||
722 | // simulate modifier+wheel | ||||
723 | quint32 timestamp = 1; | ||||
724 | QFETCH(bool, capsLock); | ||||
725 | if (capsLock) { | ||||
726 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | ||||
727 | } | ||||
728 | QFETCH(int, modifierKey); | ||||
729 | kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); | ||||
730 | kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); | ||||
731 | QCOMPARE(c->opacity(), 0.6); | ||||
732 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | ||||
733 | QCOMPARE(c->opacity(), 0.5); | ||||
734 | kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); | ||||
735 | if (capsLock) { | ||||
736 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||||
737 | } | ||||
738 | } | ||||
739 | | ||||
566 | } | 740 | } | ||
567 | 741 | | |||
568 | WAYLANDTEST_MAIN(KWin::DecorationInputTest) | 742 | WAYLANDTEST_MAIN(KWin::DecorationInputTest) | ||
569 | #include "decoration_input_test.moc" | 743 | #include "decoration_input_test.moc" |