Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 54 | private Q_SLOTS: | |||
---|---|---|---|---|---|
65 | void testScrollAction(); | 65 | void testScrollAction(); | ||
66 | void testFocusFollowsMouse(); | 66 | void testFocusFollowsMouse(); | ||
67 | void testMouseActionInactiveWindow_data(); | 67 | void testMouseActionInactiveWindow_data(); | ||
68 | void testMouseActionInactiveWindow(); | 68 | void testMouseActionInactiveWindow(); | ||
69 | void testMouseActionActiveWindow_data(); | 69 | void testMouseActionActiveWindow_data(); | ||
70 | void testMouseActionActiveWindow(); | 70 | void testMouseActionActiveWindow(); | ||
71 | void testCursorImage(); | 71 | void testCursorImage(); | ||
72 | void testEffectOverrideCursorImage(); | 72 | void testEffectOverrideCursorImage(); | ||
73 | void testPopup(); | ||||
73 | 74 | | |||
74 | private: | 75 | private: | ||
75 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | 76 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | ||
76 | KWayland::Client::Compositor *m_compositor = nullptr; | 77 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
77 | KWayland::Client::Seat *m_seat = nullptr; | 78 | KWayland::Client::Seat *m_seat = nullptr; | ||
78 | KWayland::Client::Shell *m_shell = nullptr; | 79 | KWayland::Client::Shell *m_shell = nullptr; | ||
79 | }; | 80 | }; | ||
80 | 81 | | |||
▲ Show 20 Lines • Show All 832 Lines • ▼ Show 20 Line(s) | 848 | { | |||
913 | QVERIFY(!enteredSpy.wait(100)); | 914 | QVERIFY(!enteredSpy.wait(100)); | ||
914 | 915 | | |||
915 | // after ending the interception we should get an enter event | 916 | // after ending the interception we should get an enter event | ||
916 | effects->stopMouseInterception(effect.data()); | 917 | effects->stopMouseInterception(effect.data()); | ||
917 | QVERIFY(enteredSpy.wait()); | 918 | QVERIFY(enteredSpy.wait()); | ||
918 | QVERIFY(p->cursorImage().isNull()); | 919 | QVERIFY(p->cursorImage().isNull()); | ||
919 | } | 920 | } | ||
920 | 921 | | |||
922 | void PointerInputTest::testPopup() | ||||
923 | { | ||||
924 | // this test validates the basic popup behavior | ||||
925 | // a button press outside the window should dismiss the popup | ||||
926 | | ||||
927 | // first create a parent surface | ||||
928 | using namespace KWayland::Client; | ||||
929 | auto pointer = m_seat->createPointer(m_seat); | ||||
930 | QVERIFY(pointer); | ||||
931 | QVERIFY(pointer->isValid()); | ||||
932 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||||
933 | QVERIFY(enteredSpy.isValid()); | ||||
934 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||||
935 | QVERIFY(leftSpy.isValid()); | ||||
936 | QSignalSpy buttonStateChangedSpy(pointer, &Pointer::buttonStateChanged); | ||||
937 | QVERIFY(buttonStateChangedSpy.isValid()); | ||||
938 | QSignalSpy motionSpy(pointer, &Pointer::motion); | ||||
939 | QVERIFY(motionSpy.isValid()); | ||||
940 | | ||||
941 | Cursor::setPos(800, 800); | ||||
942 | | ||||
943 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
944 | QVERIFY(clientAddedSpy.isValid()); | ||||
945 | Surface *surface = Test::createSurface(m_compositor); | ||||
946 | QVERIFY(surface); | ||||
947 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||||
948 | QVERIFY(shellSurface); | ||||
949 | render(surface); | ||||
950 | QVERIFY(clientAddedSpy.wait()); | ||||
951 | AbstractClient *window = workspace()->activeClient(); | ||||
952 | QVERIFY(window); | ||||
953 | QCOMPARE(window->hasPopupGrab(), false); | ||||
954 | // move pointer into window | ||||
955 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||||
956 | Cursor::setPos(window->geometry().center()); | ||||
957 | QVERIFY(enteredSpy.wait()); | ||||
958 | // click inside window to create serial | ||||
959 | quint32 timestamp = 0; | ||||
960 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||||
961 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||||
962 | QVERIFY(buttonStateChangedSpy.wait()); | ||||
963 | | ||||
964 | // now create the popup surface | ||||
965 | Surface *popupSurface = Test::createSurface(m_compositor); | ||||
966 | QVERIFY(popupSurface); | ||||
967 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | ||||
968 | QVERIFY(popupShellSurface); | ||||
969 | QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); | ||||
970 | QVERIFY(popupDoneSpy.isValid()); | ||||
971 | // TODO: proper serial | ||||
972 | popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); | ||||
973 | render(popupSurface); | ||||
974 | QVERIFY(clientAddedSpy.wait()); | ||||
975 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||||
976 | QVERIFY(popupClient); | ||||
977 | QVERIFY(popupClient != window); | ||||
978 | QCOMPARE(window, workspace()->activeClient()); | ||||
979 | QCOMPARE(popupClient->transientFor(), window); | ||||
980 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | ||||
981 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||||
982 | | ||||
983 | // let's move the pointer into the center of the window | ||||
984 | Cursor::setPos(popupClient->geometry().center()); | ||||
985 | QVERIFY(enteredSpy.wait()); | ||||
986 | QCOMPARE(enteredSpy.count(), 2); | ||||
987 | QCOMPARE(leftSpy.count(), 1); | ||||
988 | QCOMPARE(pointer->enteredSurface(), popupSurface); | ||||
989 | | ||||
990 | // let's move the pointer outside of the popup window | ||||
991 | // this should not really change anything, it gets a leave event | ||||
992 | Cursor::setPos(popupClient->geometry().bottomRight() + QPoint(2, 2)); | ||||
993 | QVERIFY(leftSpy.wait()); | ||||
994 | QCOMPARE(leftSpy.count(), 2); | ||||
995 | QVERIFY(popupDoneSpy.isEmpty()); | ||||
996 | // now click, should trigger popupDone | ||||
997 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||||
998 | QVERIFY(popupDoneSpy.wait()); | ||||
999 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||||
1000 | } | ||||
1001 | | ||||
921 | } | 1002 | } | ||
922 | 1003 | | |||
923 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | 1004 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | ||
924 | #include "pointer_input.moc" | 1005 | #include "pointer_input.moc" |