| 1202 | }; |
| 1203 | |
| 1204 | void PointerInputTest::testEffectOverrideCursorImage() |
| 1205 | { |
| 1206 | // this test verifies the effect cursor override handling |
| 1207 | |
| 1208 | // we need a pointer to get the enter event and set a cursor |
| 1209 | std::unique_ptr<KWayland::Client::Pointer> pointer(m_seat->createPointer()); |
| 1210 | std::unique_ptr<Test::CursorShapeDeviceV1> cursorShapeDevice(Test::createCursorShapeDeviceV1(pointer.get())); |
| 1211 | QSignalSpy enteredSpy(pointer.get(), &KWayland::Client::Pointer::entered); |
| 1212 | QSignalSpy leftSpy(pointer.get(), &KWayland::Client::Pointer::left); |
| 1213 | QSignalSpy cursorChanged(Cursors::self(), &Cursors::currentCursorChanged); |
| 1214 | |
| 1215 | // move cursor somewhere the new window won't open |
| 1216 | input()->pointer()->warp(QPointF(800, 800)); |
| 1217 | |
| 1218 | // now let's create a window |
| 1219 | QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); |
| 1220 | std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface(); |
| 1221 | QVERIFY(surface); |
| 1222 | std::unique_ptr<Test::XdgToplevel> shellSurface = Test::createXdgToplevelSurface(surface.get()); |
| 1223 | QVERIFY(shellSurface); |
| 1224 | render(surface.get()); |
| 1225 | QVERIFY(windowAddedSpy.wait()); |
| 1226 | Window *window = workspace()->activeWindow(); |
| 1227 | QVERIFY(window); |
| 1228 | |
| 1229 | // and move cursor to the window |
| 1230 | QVERIFY(!window->frameGeometry().contains(QPoint(800, 800))); |
| 1231 | input()->pointer()->warp(window->frameGeometry().center()); |
| 1232 | QVERIFY(enteredSpy.wait()); |
| 1233 | cursorShapeDevice->set_shape(enteredSpy.last().at(0).value<quint32>(), Test::CursorShapeDeviceV1::shape_wait); |
| 1234 | QVERIFY(cursorChanged.wait()); |
| 1235 | QCOMPARE(currentCursorShape(), QByteArray("wait")); |
| 1236 | |
| 1237 | // now create an effect and set an override cursor |
| 1238 | std::unique_ptr<HelperEffect> effect(new HelperEffect); |
| 1239 | effects->startMouseInterception(effect.get(), Qt::SizeAllCursor); |
| 1240 | QCOMPARE(currentCursorShape(), QByteArrayLiteral("all-scroll")); |
| 1241 | |
| 1242 | // let's change to arrow cursor, this should be our fallback |
| 1243 | effects->defineCursor(Qt::ArrowCursor); |
| 1244 | QCOMPARE(currentCursorShape(), QByteArrayLiteral("default")); |
| 1245 | |
| 1246 | // back to size all |
| 1247 | effects->defineCursor(Qt::SizeAllCursor); |
| 1248 | QCOMPARE(currentCursorShape(), QByteArrayLiteral("all-scroll")); |
| 1249 | |
| 1250 | // move cursor outside the window area |
| 1251 | input()->pointer()->warp(QPointF(800, 800)); |
| 1252 | QCOMPARE(currentCursorShape(), QByteArrayLiteral("all-scroll")); |
| 1253 | |
| 1254 | // move cursor to area of window |
| 1255 | input()->pointer()->warp(window->frameGeometry().center()); |
| 1256 | // this should not result in an enter event |
| 1257 | QVERIFY(Test::waylandSync()); |
| 1258 | QCOMPARE(enteredSpy.count(), 1); |
| 1259 | |
| 1260 | // after ending the interception we should get an enter event |
| 1261 | effects->stopMouseInterception(effect.get()); |
nothing calls this directly
no test coverage detected