Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 56 | private Q_SLOTS: | |||
---|---|---|---|---|---|
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 | void testWindowUnderCursorWhileButtonPressed(); | ||
79 | void testConfineToScreenGeometry_data(); | ||||
80 | void testConfineToScreenGeometry(); | ||||
79 | 81 | | |||
80 | private: | 82 | private: | ||
81 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | 83 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | ||
82 | KWayland::Client::Compositor *m_compositor = nullptr; | 84 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
83 | KWayland::Client::Seat *m_seat = nullptr; | 85 | KWayland::Client::Seat *m_seat = nullptr; | ||
84 | KWayland::Client::Shell *m_shell = nullptr; | 86 | KWayland::Client::Shell *m_shell = nullptr; | ||
85 | }; | 87 | }; | ||
86 | 88 | | |||
▲ Show 20 Lines • Show All 1100 Lines • ▼ Show 20 Line(s) | 1141 | { | |||
1187 | 1189 | | |||
1188 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1190 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1189 | // now that the button is no longer pressed we should get the leave event | 1191 | // now that the button is no longer pressed we should get the leave event | ||
1190 | QVERIFY(leftSpy.wait()); | 1192 | QVERIFY(leftSpy.wait()); | ||
1191 | QCOMPARE(leftSpy.count(), 1); | 1193 | QCOMPARE(leftSpy.count(), 1); | ||
1192 | QCOMPARE(enteredSpy.count(), 2); | 1194 | QCOMPARE(enteredSpy.count(), 2); | ||
1193 | } | 1195 | } | ||
1194 | 1196 | | |||
1197 | void PointerInputTest::testConfineToScreenGeometry_data() | ||||
1198 | { | ||||
1199 | QTest::addColumn<QPoint>("startPos"); | ||||
1200 | QTest::addColumn<QPoint>("targetPos"); | ||||
1201 | QTest::addColumn<QPoint>("expectedPos"); | ||||
1202 | | ||||
1203 | // screen layout: | ||||
1204 | // | ||||
1205 | // +----------+----------+---------+ | ||||
1206 | // | left | top | right | | ||||
1207 | // +----------+----------+---------+ | ||||
1208 | // | bottom | | ||||
1209 | // +----------+ | ||||
1210 | // | ||||
1211 | | ||||
1212 | QTest::newRow("move top-left - left screen") << QPoint(640, 512) << QPoint(-100, -100) << QPoint(0, 0); | ||||
1213 | QTest::newRow("move top - left screen") << QPoint(640, 512) << QPoint(640, -100) << QPoint(640, 0); | ||||
1214 | QTest::newRow("move top-right - left screen") << QPoint(640, 512) << QPoint(1380, -100) << QPoint(1380, 0); | ||||
1215 | QTest::newRow("move right - left screen") << QPoint(640, 512) << QPoint(1380, 512) << QPoint(1380, 512); | ||||
1216 | QTest::newRow("move bottom-right - left screen") << QPoint(640, 512) << QPoint(1380, 1124) << QPoint(1380, 1124); | ||||
1217 | QTest::newRow("move bottom - left screen") << QPoint(640, 512) << QPoint(640, 1124) << QPoint(640, 1023); | ||||
1218 | QTest::newRow("move bottom-left - left screen") << QPoint(640, 512) << QPoint(-100, 1124) << QPoint(0, 1023); | ||||
1219 | QTest::newRow("move left - left screen") << QPoint(640, 512) << QPoint(-100, 512) << QPoint(0, 512); | ||||
1220 | | ||||
1221 | QTest::newRow("move top-left - top screen") << QPoint(1920, 512) << QPoint(1180, -100) << QPoint(1180, 0); | ||||
1222 | QTest::newRow("move top - top screen") << QPoint(1920, 512) << QPoint(1920, -100) << QPoint(1920, 0); | ||||
1223 | QTest::newRow("move top-right - top screen") << QPoint(1920, 512) << QPoint(2660, -100) << QPoint(2660, 0); | ||||
1224 | QTest::newRow("move right - top screen") << QPoint(1920, 512) << QPoint(2660, 512) << QPoint(2660, 512); | ||||
1225 | QTest::newRow("move bottom-right - top screen") << QPoint(1920, 512) << QPoint(2660, 1124) << QPoint(2559, 1023); | ||||
1226 | QTest::newRow("move bottom - top screen") << QPoint(1920, 512) << QPoint(1920, 1124) << QPoint(1920, 1124); | ||||
1227 | QTest::newRow("move bottom-left - top screen") << QPoint(1920, 512) << QPoint(1180, 1124) << QPoint(1280, 1023); | ||||
1228 | QTest::newRow("move left - top screen") << QPoint(1920, 512) << QPoint(1180, 512) << QPoint(1180, 512); | ||||
1229 | | ||||
1230 | QTest::newRow("move top-left - right screen") << QPoint(3200, 512) << QPoint(2460, -100) << QPoint(2460, 0); | ||||
1231 | QTest::newRow("move top - right screen") << QPoint(3200, 512) << QPoint(3200, -100) << QPoint(3200, 0); | ||||
1232 | QTest::newRow("move top-right - right screen") << QPoint(3200, 512) << QPoint(3940, -100) << QPoint(3839, 0); | ||||
1233 | QTest::newRow("move right - right screen") << QPoint(3200, 512) << QPoint(3940, 512) << QPoint(3839, 512); | ||||
1234 | QTest::newRow("move bottom-right - right screen") << QPoint(3200, 512) << QPoint(3940, 1124) << QPoint(3839, 1023); | ||||
1235 | QTest::newRow("move bottom - right screen") << QPoint(3200, 512) << QPoint(3200, 1124) << QPoint(3200, 1023); | ||||
1236 | QTest::newRow("move bottom-left - right screen") << QPoint(3200, 512) << QPoint(2460, 1124) << QPoint(2460, 1124); | ||||
1237 | QTest::newRow("move left - right screen") << QPoint(3200, 512) << QPoint(2460, 512) << QPoint(2460, 512); | ||||
1238 | | ||||
1239 | QTest::newRow("move top-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 924) << QPoint(1180, 924); | ||||
1240 | QTest::newRow("move top - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 924) << QPoint(1920, 924); | ||||
1241 | QTest::newRow("move top-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 924) << QPoint(2660, 924); | ||||
1242 | QTest::newRow("move right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 1536) << QPoint(2559, 1536); | ||||
1243 | QTest::newRow("move bottom-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 2148) << QPoint(2559, 2047); | ||||
1244 | QTest::newRow("move bottom - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 2148) << QPoint(1920, 2047); | ||||
1245 | QTest::newRow("move bottom-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 2148) << QPoint(1280, 2047); | ||||
1246 | QTest::newRow("move left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 1536) << QPoint(1280, 1536); | ||||
1247 | } | ||||
1248 | | ||||
1249 | void PointerInputTest::testConfineToScreenGeometry() | ||||
1250 | { | ||||
1251 | // this test verifies that pointer belongs to at least one screen | ||||
1252 | // after moving it to off-screen area | ||||
1253 | | ||||
1254 | // unload the Present Windows effect because it pushes back | ||||
1255 | // pointer if it's at (0, 0) | ||||
1256 | static_cast<EffectsHandlerImpl*>(effects)->unloadEffect(QStringLiteral("presentwindows")); | ||||
1257 | | ||||
1258 | // setup screen layout | ||||
1259 | const QVector<QRect> geometries { | ||||
1260 | QRect(0, 0, 1280, 1024), | ||||
1261 | QRect(1280, 0, 1280, 1024), | ||||
1262 | QRect(2560, 0, 1280, 1024), | ||||
1263 | QRect(1280, 1024, 1280, 1024) | ||||
1264 | }; | ||||
1265 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", | ||||
1266 | Qt::DirectConnection, | ||||
1267 | Q_ARG(int, geometries.count()), | ||||
1268 | Q_ARG(QVector<QRect>, geometries)); | ||||
1269 | QCOMPARE(screens()->count(), geometries.count()); | ||||
1270 | QCOMPARE(screens()->geometry(0), geometries.at(0)); | ||||
1271 | QCOMPARE(screens()->geometry(1), geometries.at(1)); | ||||
1272 | QCOMPARE(screens()->geometry(2), geometries.at(2)); | ||||
1273 | QCOMPARE(screens()->geometry(3), geometries.at(3)); | ||||
1274 | | ||||
1275 | // move pointer to initial position | ||||
1276 | QFETCH(QPoint, startPos); | ||||
1277 | Cursor::setPos(startPos); | ||||
1278 | QCOMPARE(Cursor::pos(), startPos); | ||||
1279 | | ||||
1280 | // perform movement | ||||
1281 | QFETCH(QPoint, targetPos); | ||||
1282 | kwinApp()->platform()->pointerMotion(targetPos, 1); | ||||
1283 | | ||||
1284 | QFETCH(QPoint, expectedPos); | ||||
1285 | QCOMPARE(Cursor::pos(), expectedPos); | ||||
1286 | } | ||||
1287 | | ||||
1195 | } | 1288 | } | ||
1196 | 1289 | | |||
1197 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | 1290 | WAYLANDTEST_MAIN(KWin::PointerInputTest) | ||
1198 | #include "pointer_input.moc" | 1291 | #include "pointer_input.moc" |