diff options
author | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2022-10-24 22:13:33 +0300 |
---|---|---|
committer | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2022-10-26 22:34:20 +0300 |
commit | f1e71327d462d2dae0b46677bbc478afb0d1b2f7 (patch) | |
tree | 0e5e8c08dd8e71d94cc5aeaa1b27bdd8c67eeda7 /tests/auto/client/seat/tst_seat.cpp | |
parent | 763b3dba2c0e62926072a40373aa7685a6264b7b (diff) | |
download | qtwayland-f1e71327d462d2dae0b46677bbc478afb0d1b2f7.tar.gz |
Client: Add support for high-resolution scrolling
With wl_pointer version 8, the axis_discrete event is replaced with the
axis_value120 event.
The main difference between axis_discrete and axis_value120 is that the
latter carries scroll deltas that can be fractions of 120, e.g. 30, etc.
See also https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/72
Change-Id: I4f724ead7ba146dde6d8975fa4edfcfca761769d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/client/seat/tst_seat.cpp')
-rw-r--r-- | tests/auto/client/seat/tst_seat.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/tests/auto/client/seat/tst_seat.cpp b/tests/auto/client/seat/tst_seat.cpp index 68749486..8a9375d6 100644 --- a/tests/auto/client/seat/tst_seat.cpp +++ b/tests/auto/client/seat/tst_seat.cpp @@ -18,7 +18,7 @@ public: removeAll<Seat>(); uint capabilities = MockCompositor::Seat::capability_pointer | MockCompositor::Seat::capability_touch; - int version = 7; + int version = 8; add<Seat>(capabilities, version); }); } @@ -40,8 +40,7 @@ private slots: void fingerScroll(); void fingerScrollSlow(); void continuousScroll(); - void wheelDiscreteScroll_data(); - void wheelDiscreteScroll(); + void highResolutionScroll(); // Touch tests void createsTouch(); @@ -56,13 +55,13 @@ private slots: void tst_seat::bindsToSeat() { QCOMPOSITOR_COMPARE(get<Seat>()->resourceMap().size(), 1); - QCOMPOSITOR_COMPARE(get<Seat>()->resourceMap().first()->version(), 7); + QCOMPOSITOR_COMPARE(get<Seat>()->resourceMap().first()->version(), 8); } void tst_seat::createsPointer() { QCOMPOSITOR_TRY_COMPARE(pointer()->resourceMap().size(), 1); - QCOMPOSITOR_TRY_COMPARE(pointer()->resourceMap().first()->version(), 7); + QCOMPOSITOR_TRY_COMPARE(pointer()->resourceMap().first()->version(), 8); } void tst_seat::setsCursorOnEnter() @@ -320,28 +319,38 @@ void tst_seat::fingerScrollSlow() QCOMPARE(accumulated.y(), -1); } -void tst_seat::wheelDiscreteScroll_data() -{ - QTest::addColumn<uint>("source"); - QTest::newRow("wheel") << uint(Pointer::axis_source_wheel); - QTest::newRow("wheel tilt") << uint(Pointer::axis_source_wheel_tilt); -} - -void tst_seat::wheelDiscreteScroll() +void tst_seat::highResolutionScroll() { WheelWindow window; QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); - QFETCH(uint, source); - exec([=] { auto *p = pointer(); auto *c = client(); p->sendEnter(xdgToplevel()->surface(), {32, 32}); p->sendFrame(c); - p->sendAxisSource(c, Pointer::axis_source(source)); - p->sendAxisDiscrete(c, Pointer::axis_vertical_scroll, 1); // 1 click downwards - p->sendAxis(c, Pointer::axis_vertical_scroll, 1.0); + p->sendAxisSource(c, Pointer::axis_source_wheel); + p->sendAxisValue120(c, Pointer::axis_vertical_scroll, 30); // quarter of a click + p->sendAxis(c, Pointer::axis_vertical_scroll, 3.75); + p->sendFrame(c); + }); + + QTRY_VERIFY(!window.m_events.empty()); + { + auto e = window.m_events.takeFirst(); + QCOMPARE(e.phase, Qt::NoScrollPhase); + QVERIFY(qAbs(e.angleDelta.x()) <= qAbs(e.angleDelta.y())); // Vertical scroll + QCOMPARE(e.angleDelta, QPoint(0, -30)); + // Click scrolls are not continuous and should not have a pixel delta + QCOMPARE(e.pixelDelta, QPoint(0, 0)); + } + + exec([=] { + auto *p = pointer(); + auto *c = client(); + p->sendAxisSource(c, Pointer::axis_source_wheel); + p->sendAxisValue120(c, Pointer::axis_vertical_scroll, 90); // complete the click + p->sendAxis(c, Pointer::axis_vertical_scroll, 11.25); p->sendFrame(c); }); @@ -350,10 +359,7 @@ void tst_seat::wheelDiscreteScroll() auto e = window.m_events.takeFirst(); QCOMPARE(e.phase, Qt::NoScrollPhase); QVERIFY(qAbs(e.angleDelta.x()) <= qAbs(e.angleDelta.y())); // Vertical scroll - // According to the docs the angle delta is in eights of a degree and most mice have - // 1 click = 15 degrees. The angle delta should therefore be: - // 15 degrees / (1/8 eights per degrees) = 120 eights of degrees. - QCOMPARE(e.angleDelta, QPoint(0, -120)); + QCOMPARE(e.angleDelta, QPoint(0, -90)); // Click scrolls are not continuous and should not have a pixel delta QCOMPARE(e.pixelDelta, QPoint(0, 0)); } @@ -388,7 +394,7 @@ void tst_seat::continuousScroll() void tst_seat::createsTouch() { QCOMPOSITOR_TRY_COMPARE(touch()->resourceMap().size(), 1); - QCOMPOSITOR_TRY_COMPARE(touch()->resourceMap().first()->version(), 7); + QCOMPOSITOR_TRY_COMPARE(touch()->resourceMap().first()->version(), 8); } class TouchWindow : public QRasterWindow { |