Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/internal_window.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 48 | private Q_SLOTS: | |||
---|---|---|---|---|---|
56 | void testKeyboard(); | 56 | void testKeyboard(); | ||
57 | void testKeyboardShowWithoutActivating(); | 57 | void testKeyboardShowWithoutActivating(); | ||
58 | void testKeyboardTriggersLeave(); | 58 | void testKeyboardTriggersLeave(); | ||
59 | void testTouch(); | 59 | void testTouch(); | ||
60 | void testOpacity(); | 60 | void testOpacity(); | ||
61 | void testMove(); | 61 | void testMove(); | ||
62 | void testSkipCloseAnimation_data(); | 62 | void testSkipCloseAnimation_data(); | ||
63 | void testSkipCloseAnimation(); | 63 | void testSkipCloseAnimation(); | ||
64 | void testModifierClickUnrestrictedMove(); | ||||
65 | void testModifierScroll(); | ||||
64 | }; | 66 | }; | ||
65 | 67 | | |||
66 | class HelperWindow : public QRasterWindow | 68 | class HelperWindow : public QRasterWindow | ||
67 | { | 69 | { | ||
68 | Q_OBJECT | 70 | Q_OBJECT | ||
69 | public: | 71 | public: | ||
70 | HelperWindow(); | 72 | HelperWindow(); | ||
71 | ~HelperWindow(); | 73 | ~HelperWindow(); | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
170 | { | 172 | { | ||
171 | qRegisterMetaType<KWin::ShellClient*>(); | 173 | qRegisterMetaType<KWin::ShellClient*>(); | ||
172 | qRegisterMetaType<KWin::AbstractClient*>(); | 174 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
173 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 175 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
174 | QVERIFY(workspaceCreatedSpy.isValid()); | 176 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
175 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 177 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
176 | QMetaObject::invokeMethod(kwinApp()->platform(), "setOutputCount", Qt::DirectConnection, Q_ARG(int, 2)); | 178 | QMetaObject::invokeMethod(kwinApp()->platform(), "setOutputCount", Qt::DirectConnection, Q_ARG(int, 2)); | ||
177 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 179 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
180 | kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | ||||
178 | 181 | | |||
179 | kwinApp()->start(); | 182 | kwinApp()->start(); | ||
180 | QVERIFY(workspaceCreatedSpy.wait()); | 183 | QVERIFY(workspaceCreatedSpy.wait()); | ||
181 | QCOMPARE(screens()->count(), 2); | 184 | QCOMPARE(screens()->count(), 2); | ||
182 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 185 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
183 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 186 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
184 | waylandServer()->initWorkspace(); | 187 | waylandServer()->initWorkspace(); | ||
185 | } | 188 | } | ||
Show All 21 Lines | 203 | { | |||
207 | win.show(); | 210 | win.show(); | ||
208 | 211 | | |||
209 | QVERIFY(clientAddedSpy.wait()); | 212 | QVERIFY(clientAddedSpy.wait()); | ||
210 | QCOMPARE(clientAddedSpy.count(), 1); | 213 | QCOMPARE(clientAddedSpy.count(), 1); | ||
211 | QVERIFY(!workspace()->activeClient()); | 214 | QVERIFY(!workspace()->activeClient()); | ||
212 | ShellClient *c = clientAddedSpy.first().first().value<ShellClient*>(); | 215 | ShellClient *c = clientAddedSpy.first().first().value<ShellClient*>(); | ||
213 | QVERIFY(c->isInternal()); | 216 | QVERIFY(c->isInternal()); | ||
214 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | 217 | QCOMPARE(c->icon().name(), QStringLiteral("wayland")); | ||
218 | QVERIFY(!c->isDecorated()); | ||||
215 | QCOMPARE(workspace()->findToplevel(&win), c); | 219 | QCOMPARE(workspace()->findToplevel(&win), c); | ||
216 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 100)); | 220 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 100)); | ||
217 | QVERIFY(c->isShown(false)); | 221 | QVERIFY(c->isShown(false)); | ||
218 | QVERIFY(workspace()->xStackingOrder().contains(c)); | 222 | QVERIFY(workspace()->xStackingOrder().contains(c)); | ||
219 | 223 | | |||
220 | QSignalSpy enterSpy(&win, &HelperWindow::entered); | 224 | QSignalSpy enterSpy(&win, &HelperWindow::entered); | ||
221 | QVERIFY(enterSpy.isValid()); | 225 | QVERIFY(enterSpy.isValid()); | ||
222 | QSignalSpy leaveSpy(&win, &HelperWindow::left); | 226 | QSignalSpy leaveSpy(&win, &HelperWindow::left); | ||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Line(s) | 572 | { | |||
584 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial); | 588 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial); | ||
585 | QCOMPARE(skipCloseChangedSpy.count(), 1); | 589 | QCOMPARE(skipCloseChangedSpy.count(), 1); | ||
586 | QCOMPARE(internalClient->skipsCloseAnimation(), !initial); | 590 | QCOMPARE(internalClient->skipsCloseAnimation(), !initial); | ||
587 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial); | 591 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial); | ||
588 | QCOMPARE(skipCloseChangedSpy.count(), 2); | 592 | QCOMPARE(skipCloseChangedSpy.count(), 2); | ||
589 | QCOMPARE(internalClient->skipsCloseAnimation(), initial); | 593 | QCOMPARE(internalClient->skipsCloseAnimation(), initial); | ||
590 | } | 594 | } | ||
591 | 595 | | |||
596 | void InternalWindowTest::testModifierClickUnrestrictedMove() | ||||
597 | { | ||||
598 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
599 | QVERIFY(clientAddedSpy.isValid()); | ||||
600 | HelperWindow win; | ||||
601 | win.setGeometry(0, 0, 100, 100); | ||||
602 | win.setFlags(win.flags() & ~Qt::FramelessWindowHint); | ||||
603 | win.show(); | ||||
604 | QVERIFY(clientAddedSpy.wait()); | ||||
605 | QCOMPARE(clientAddedSpy.count(), 1); | ||||
606 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
607 | QVERIFY(internalClient); | ||||
608 | QVERIFY(internalClient->isDecorated()); | ||||
609 | | ||||
610 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
611 | group.writeEntry("CommandAllKey", "Alt"); | ||||
612 | group.writeEntry("CommandAll1", "Move"); | ||||
613 | group.writeEntry("CommandAll2", "Move"); | ||||
614 | group.writeEntry("CommandAll3", "Move"); | ||||
615 | group.sync(); | ||||
616 | workspace()->slotReconfigure(); | ||||
617 | QCOMPARE(options->commandAllModifier(), Qt::AltModifier); | ||||
618 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||||
619 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||||
620 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||||
621 | | ||||
622 | // move cursor on window | ||||
623 | Cursor::setPos(internalClient->geometry().center()); | ||||
624 | | ||||
625 | // simulate modifier+click | ||||
626 | quint32 timestamp = 1; | ||||
627 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); | ||||
628 | QVERIFY(!internalClient->isMove()); | ||||
629 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||||
630 | QVERIFY(internalClient->isMove()); | ||||
631 | // release modifier should not change it | ||||
632 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||||
633 | QVERIFY(internalClient->isMove()); | ||||
634 | // but releasing the key should end move/resize | ||||
635 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||||
636 | QVERIFY(!internalClient->isMove()); | ||||
637 | } | ||||
638 | | ||||
639 | void InternalWindowTest::testModifierScroll() | ||||
640 | { | ||||
641 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
642 | QVERIFY(clientAddedSpy.isValid()); | ||||
643 | HelperWindow win; | ||||
644 | win.setGeometry(0, 0, 100, 100); | ||||
645 | win.setFlags(win.flags() & ~Qt::FramelessWindowHint); | ||||
646 | win.show(); | ||||
647 | QVERIFY(clientAddedSpy.wait()); | ||||
648 | QCOMPARE(clientAddedSpy.count(), 1); | ||||
649 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
650 | QVERIFY(internalClient); | ||||
651 | QVERIFY(internalClient->isDecorated()); | ||||
652 | | ||||
653 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
654 | group.writeEntry("CommandAllKey", "Alt"); | ||||
655 | group.writeEntry("CommandAllWheel", "change opacity"); | ||||
656 | group.sync(); | ||||
657 | workspace()->slotReconfigure(); | ||||
658 | | ||||
659 | // move cursor on window | ||||
660 | Cursor::setPos(internalClient->geometry().center()); | ||||
661 | | ||||
662 | // set the opacity to 0.5 | ||||
663 | internalClient->setOpacity(0.5); | ||||
664 | QCOMPARE(internalClient->opacity(), 0.5); | ||||
665 | quint32 timestamp = 1; | ||||
666 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); | ||||
667 | kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); | ||||
668 | QCOMPARE(internalClient->opacity(), 0.6); | ||||
669 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | ||||
670 | QCOMPARE(internalClient->opacity(), 0.5); | ||||
671 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||||
672 | } | ||||
673 | | ||||
592 | } | 674 | } | ||
593 | 675 | | |||
594 | WAYLANDTEST_MAIN(KWin::InternalWindowTest) | 676 | WAYLANDTEST_MAIN(KWin::InternalWindowTest) | ||
595 | #include "internal_window.moc" | 677 | #include "internal_window.moc" |