Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | 56 | private Q_SLOTS: | |||
---|---|---|---|---|---|
70 | void testMouseActionInactiveWindow_data(); | 70 | void testMouseActionInactiveWindow_data(); | ||
71 | void testMouseActionInactiveWindow(); | 71 | void testMouseActionInactiveWindow(); | ||
72 | void testMouseActionActiveWindow_data(); | 72 | void testMouseActionActiveWindow_data(); | ||
73 | void testMouseActionActiveWindow(); | 73 | void testMouseActionActiveWindow(); | ||
74 | void testCursorImage(); | 74 | void testCursorImage(); | ||
75 | void testEffectOverrideCursorImage(); | 75 | void testEffectOverrideCursorImage(); | ||
76 | void testPopup(); | 76 | void testPopup(); | ||
77 | void testDecoCancelsPopup(); | 77 | void testDecoCancelsPopup(); | ||
78 | void testWindowUnderCursorWhileButtonPressed(); | ||||
78 | 79 | | |||
79 | private: | 80 | private: | ||
80 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | 81 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | ||
81 | KWayland::Client::Compositor *m_compositor = nullptr; | 82 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
82 | KWayland::Client::Seat *m_seat = nullptr; | 83 | KWayland::Client::Seat *m_seat = nullptr; | ||
83 | KWayland::Client::Shell *m_shell = nullptr; | 84 | KWayland::Client::Shell *m_shell = nullptr; | ||
84 | }; | 85 | }; | ||
85 | 86 | | |||
▲ Show 20 Lines • Show All 1034 Lines • ▼ Show 20 Line(s) | 1052 | { | |||
1120 | // let's move the pointer into the center of the deco | 1121 | // let's move the pointer into the center of the deco | ||
1121 | Cursor::setPos(window->geometry().center().x(), window->y() + (window->height() - window->clientSize().height()) / 2); | 1122 | Cursor::setPos(window->geometry().center().x(), window->y() + (window->height() - window->clientSize().height()) / 2); | ||
1122 | 1123 | | |||
1123 | kwinApp()->platform()->pointerButtonPressed(BTN_RIGHT, timestamp++); | 1124 | kwinApp()->platform()->pointerButtonPressed(BTN_RIGHT, timestamp++); | ||
1124 | QVERIFY(popupDoneSpy.wait()); | 1125 | QVERIFY(popupDoneSpy.wait()); | ||
1125 | kwinApp()->platform()->pointerButtonReleased(BTN_RIGHT, timestamp++); | 1126 | kwinApp()->platform()->pointerButtonReleased(BTN_RIGHT, timestamp++); | ||
1126 | } | 1127 | } | ||
1127 | 1128 | | |||
1129 | void PointerInputTest::testWindowUnderCursorWhileButtonPressed() | ||||
1130 | { | ||||
1131 | // this test verifies that opening a window underneath the mouse cursor does not | ||||
1132 | // trigger a leave event if a button is pressed | ||||
1133 | // see BUG: 372876 | ||||
1134 | | ||||
1135 | // first create a parent surface | ||||
1136 | using namespace KWayland::Client; | ||||
1137 | auto pointer = m_seat->createPointer(m_seat); | ||||
1138 | QVERIFY(pointer); | ||||
1139 | QVERIFY(pointer->isValid()); | ||||
1140 | QSignalSpy enteredSpy(pointer, &Pointer::entered); | ||||
1141 | QVERIFY(enteredSpy.isValid()); | ||||
1142 | QSignalSpy leftSpy(pointer, &Pointer::left); | ||||
1143 | QVERIFY(leftSpy.isValid()); | ||||
1144 | | ||||
1145 | Cursor::setPos(800, 800); | ||||
1146 | QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||||
1147 | QVERIFY(clientAddedSpy.isValid()); | ||||
1148 | Surface *surface = Test::createSurface(m_compositor); | ||||
1149 | QVERIFY(surface); | ||||
1150 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||||
1151 | QVERIFY(shellSurface); | ||||
1152 | render(surface); | ||||
1153 | QVERIFY(clientAddedSpy.wait()); | ||||
1154 | AbstractClient *window = workspace()->activeClient(); | ||||
1155 | QVERIFY(window); | ||||
1156 | | ||||
1157 | // move cursor over window | ||||
1158 | QVERIFY(!window->geometry().contains(QPoint(800, 800))); | ||||
1159 | Cursor::setPos(window->geometry().center()); | ||||
1160 | QVERIFY(enteredSpy.wait()); | ||||
1161 | // click inside window | ||||
1162 | quint32 timestamp = 0; | ||||
1163 | kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); | ||||
1164 | | ||||
1165 | // now create a second window as transient | ||||
1166 | Surface *popupSurface = Test::createSurface(m_compositor); | ||||
1167 | QVERIFY(popupSurface); | ||||
1168 | ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); | ||||
1169 | QVERIFY(popupShellSurface); | ||||
1170 | popupShellSurface->setTransient(surface, QPoint(0, 0)); | ||||
1171 | render(popupSurface); | ||||
1172 | QVERIFY(clientAddedSpy.wait()); | ||||
1173 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | ||||
1174 | QVERIFY(popupClient); | ||||
1175 | QVERIFY(popupClient != window); | ||||
1176 | QCOMPARE(window->geometry(), popupClient->geometry()); | ||||
1177 | QVERIFY(!leftSpy.wait()); | ||||
1178 | | ||||
1179 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||||
1180 | // now that the button is no longer pressed we should get the leave event | ||||
1181 | QVERIFY(leftSpy.wait()); | ||||
1182 | QCOMPARE(leftSpy.count(), 1); | ||||
1183 | QCOMPARE(enteredSpy.count(), 2); | ||||
1184 | } | ||||
1185 | | ||||
1128 | } | 1186 | } | ||
1129 | 1187 | | |||
1130 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | 1188 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | ||
1131 | #include "pointer_input.moc" | 1189 | #include "pointer_input.moc" |