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 20 Lines | 203 | { | |||
206 | win.setGeometry(0, 0, 100, 100); | 209 | win.setGeometry(0, 0, 100, 100); | ||
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()); | ||
217 | QVERIFY(!c->isDecorated()); | ||||
214 | QCOMPARE(workspace()->findToplevel(&win), c); | 218 | QCOMPARE(workspace()->findToplevel(&win), c); | ||
215 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 100)); | 219 | QCOMPARE(c->geometry(), QRect(0, 0, 100, 100)); | ||
216 | QVERIFY(c->isShown(false)); | 220 | QVERIFY(c->isShown(false)); | ||
217 | QVERIFY(workspace()->xStackingOrder().contains(c)); | 221 | QVERIFY(workspace()->xStackingOrder().contains(c)); | ||
218 | 222 | | |||
219 | QSignalSpy enterSpy(&win, &HelperWindow::entered); | 223 | QSignalSpy enterSpy(&win, &HelperWindow::entered); | ||
220 | QVERIFY(enterSpy.isValid()); | 224 | QVERIFY(enterSpy.isValid()); | ||
221 | QSignalSpy leaveSpy(&win, &HelperWindow::left); | 225 | QSignalSpy leaveSpy(&win, &HelperWindow::left); | ||
▲ Show 20 Lines • Show All 361 Lines • ▼ Show 20 Line(s) | 571 | { | |||
583 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial); | 587 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial); | ||
584 | QCOMPARE(skipCloseChangedSpy.count(), 1); | 588 | QCOMPARE(skipCloseChangedSpy.count(), 1); | ||
585 | QCOMPARE(internalClient->skipsCloseAnimation(), !initial); | 589 | QCOMPARE(internalClient->skipsCloseAnimation(), !initial); | ||
586 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial); | 590 | win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial); | ||
587 | QCOMPARE(skipCloseChangedSpy.count(), 2); | 591 | QCOMPARE(skipCloseChangedSpy.count(), 2); | ||
588 | QCOMPARE(internalClient->skipsCloseAnimation(), initial); | 592 | QCOMPARE(internalClient->skipsCloseAnimation(), initial); | ||
589 | } | 593 | } | ||
590 | 594 | | |||
595 | void InternalWindowTest::testModifierClickUnrestrictedMove() | ||||
596 | { | ||||
597 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
598 | QVERIFY(clientAddedSpy.isValid()); | ||||
599 | HelperWindow win; | ||||
600 | win.setGeometry(0, 0, 100, 100); | ||||
601 | win.setFlags(win.flags() & ~Qt::FramelessWindowHint); | ||||
602 | win.show(); | ||||
603 | QVERIFY(clientAddedSpy.wait()); | ||||
604 | QCOMPARE(clientAddedSpy.count(), 1); | ||||
605 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
606 | QVERIFY(internalClient); | ||||
607 | QVERIFY(internalClient->isDecorated()); | ||||
608 | | ||||
609 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
610 | group.writeEntry("CommandAllKey", "Alt"); | ||||
611 | group.writeEntry("CommandAll1", "Move"); | ||||
612 | group.writeEntry("CommandAll2", "Move"); | ||||
613 | group.writeEntry("CommandAll3", "Move"); | ||||
614 | group.sync(); | ||||
615 | workspace()->slotReconfigure(); | ||||
616 | QCOMPARE(options->commandAllModifier(), Qt::AltModifier); | ||||
617 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||||
618 | QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); | ||||
619 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); | ||||
620 | | ||||
621 | // move cursor on window | ||||
622 | Cursor::setPos(internalClient->geometry().center()); | ||||
623 | | ||||
624 | // simulate modifier+click | ||||
625 | quint32 timestamp = 1; | ||||
626 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); | ||||
627 | QVERIFY(!internalClient->isMove()); | ||||
628 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||||
629 | QVERIFY(internalClient->isMove()); | ||||
630 | // release modifier should not change it | ||||
631 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||||
632 | QVERIFY(internalClient->isMove()); | ||||
633 | // but releasing the key should end move/resize | ||||
634 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||||
635 | QVERIFY(!internalClient->isMove()); | ||||
636 | } | ||||
637 | | ||||
638 | void InternalWindowTest::testModifierScroll() | ||||
639 | { | ||||
640 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
641 | QVERIFY(clientAddedSpy.isValid()); | ||||
642 | HelperWindow win; | ||||
643 | win.setGeometry(0, 0, 100, 100); | ||||
644 | win.setFlags(win.flags() & ~Qt::FramelessWindowHint); | ||||
645 | win.show(); | ||||
646 | QVERIFY(clientAddedSpy.wait()); | ||||
647 | QCOMPARE(clientAddedSpy.count(), 1); | ||||
648 | auto internalClient = clientAddedSpy.first().first().value<ShellClient*>(); | ||||
649 | QVERIFY(internalClient); | ||||
650 | QVERIFY(internalClient->isDecorated()); | ||||
651 | | ||||
652 | KConfigGroup group = kwinApp()->config()->group("MouseBindings"); | ||||
653 | group.writeEntry("CommandAllKey", "Alt"); | ||||
654 | group.writeEntry("CommandAllWheel", "change opacity"); | ||||
655 | group.sync(); | ||||
656 | workspace()->slotReconfigure(); | ||||
657 | | ||||
658 | // move cursor on window | ||||
659 | Cursor::setPos(internalClient->geometry().center()); | ||||
660 | | ||||
661 | // set the opacity to 0.5 | ||||
662 | internalClient->setOpacity(0.5); | ||||
663 | QCOMPARE(internalClient->opacity(), 0.5); | ||||
664 | quint32 timestamp = 1; | ||||
665 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); | ||||
666 | kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); | ||||
667 | QCOMPARE(internalClient->opacity(), 0.6); | ||||
668 | kwinApp()->platform()->pointerAxisVertical(5, timestamp++); | ||||
669 | QCOMPARE(internalClient->opacity(), 0.5); | ||||
670 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); | ||||
671 | } | ||||
672 | | ||||
591 | } | 673 | } | ||
592 | 674 | | |||
593 | WAYLANDTEST_MAIN(KWin::InternalWindowTest) | 675 | WAYLANDTEST_MAIN(KWin::InternalWindowTest) | ||
594 | #include "internal_window.moc" | 676 | #include "internal_window.moc" |