| 2024 | } |
| 2025 | |
| 2026 | void PointerInputTest::testTabletCursorSyncRelative() |
| 2027 | { |
| 2028 | // This test verifies that moving the stylus cursor doesn't reflect the mouse pointer, because it was explicitly requested. |
| 2029 | auto cfg = kwinApp()->inputConfig(); |
| 2030 | KConfigGroup tabletGroup = cfg->group(QStringLiteral("Tablet")); |
| 2031 | tabletGroup.writeEntry(QStringLiteral("SyncWithMouse"), true, KConfig::Notify); |
| 2032 | cfg->sync(); |
| 2033 | |
| 2034 | // create pointer and signal spy for enter and leave signals |
| 2035 | auto pointer = m_seat->createPointer(m_seat); |
| 2036 | QVERIFY(pointer); |
| 2037 | QVERIFY(pointer->isValid()); |
| 2038 | |
| 2039 | QSignalSpy enteredSpy(pointer, &KWayland::Client::Pointer::entered); |
| 2040 | QSignalSpy motionSpy(pointer, &KWayland::Client::Pointer::motion); |
| 2041 | |
| 2042 | // create a window |
| 2043 | QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); |
| 2044 | std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface(); |
| 2045 | QVERIFY(surface); |
| 2046 | std::unique_ptr<Test::XdgToplevel> shellSurface = Test::createXdgToplevelSurface(surface.get()); |
| 2047 | QVERIFY(shellSurface); |
| 2048 | render(surface.get()); |
| 2049 | QVERIFY(windowAddedSpy.wait()); |
| 2050 | Window *window = workspace()->activeWindow(); |
| 2051 | QVERIFY(window); |
| 2052 | |
| 2053 | // currently there should not be a focused pointer surface |
| 2054 | QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); |
| 2055 | QVERIFY(!pointer->enteredSurface()); |
| 2056 | |
| 2057 | // Start at the center of the window (50,25) |
| 2058 | // Normally for relative tablet devices this is done automatically, but in our test we need to do this. |
| 2059 | quint32 timestamp = 0; |
| 2060 | Test::pointerMotion(window->frameGeometry().center(), timestamp++); |
| 2061 | |
| 2062 | QVERIFY(enteredSpy.wait()); |
| 2063 | QCOMPARE(enteredSpy.count(), 1); |
| 2064 | |
| 2065 | // It will be 30px since the center is 25px, and we moved 5px with the mouse. |
| 2066 | QCOMPARE(enteredSpy.first().at(1).toPointF(), QPointF(50, 25)); |
| 2067 | // window should have focus |
| 2068 | QCOMPARE(pointer->enteredSurface(), surface.get()); |
| 2069 | // also on the server |
| 2070 | QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window->surface()); |
| 2071 | |
| 2072 | // Set tablet tool to relative |
| 2073 | auto tablet = static_cast<WaylandTestApplication *>(kwinApp())->virtualTablet(); |
| 2074 | tablet->setTabletToolIsRelative(true); |
| 2075 | |
| 2076 | // Move 5px down (to 50,30) |
| 2077 | Test::tabletToolProximityEvent(window->frameGeometry().center(), 0, 0, 0, 0, true, 0, timestamp++); |
| 2078 | Test::tabletToolAxisEventRelative(QPointF{0, 5}, 0, 0, 0, 0, 0, true, 0, timestamp++); |
| 2079 | Test::tabletToolProximityEvent(window->frameGeometry().center(), 0, 0, 0, 0, false, 0, timestamp++); |
| 2080 | |
| 2081 | // Move the cursor another 10px down to 50,40) |
| 2082 | Test::pointerMotionRelative({0, 10}, timestamp++); |
| 2083 |
nothing calls this directly
no test coverage detected