114 lines
3.9 KiB
Diff
114 lines
3.9 KiB
Diff
From 7f065653e2f372ee5b7e2ea4dbed6681ef41be68 Mon Sep 17 00:00:00 2001
|
|
From: David Edmundson <davidedmundson@kde.org>
|
|
Date: Tue, 07 Apr 2020 17:36:19 +0100
|
|
Subject: [PATCH] Client: Fix scroll direction with touchpads
|
|
|
|
Wayland axis events and QWheelEvents are opposite way rounds. This was
|
|
handled for the case of discrete events, but not continuous events.
|
|
|
|
This leads to touchpads moving the wrong way round compared to other
|
|
clients.
|
|
|
|
Change-Id: Iee4f5c620940a491949d4039cb3ac70649d83a2b
|
|
Pick-to: 5.15
|
|
---
|
|
|
|
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
|
|
index e0f0c6c..ed4a0eb 100644
|
|
--- a/src/client/qwaylandinputdevice.cpp
|
|
+++ b/src/client/qwaylandinputdevice.cpp
|
|
@@ -1025,6 +1025,12 @@
|
|
*accumulatedError += delta - pixelDelta;
|
|
Q_ASSERT(qAbs(accumulatedError->x()) < 1.0);
|
|
Q_ASSERT(qAbs(accumulatedError->y()) < 1.0);
|
|
+
|
|
+ // for continuous scroll events things should be
|
|
+ // in the same direction
|
|
+ // i.e converted so downwards surface co-ordinates (positive axis_value)
|
|
+ // goes to downwards in wheel event (negative value)
|
|
+ pixelDelta *= -1;
|
|
return pixelDelta;
|
|
}
|
|
|
|
diff --git a/tests/auto/client/seatv5/tst_seatv5.cpp b/tests/auto/client/seatv5/tst_seatv5.cpp
|
|
index e333082..9312c2e 100644
|
|
--- a/tests/auto/client/seatv5/tst_seatv5.cpp
|
|
+++ b/tests/auto/client/seatv5/tst_seatv5.cpp
|
|
@@ -63,6 +63,7 @@
|
|
void simpleAxis();
|
|
void fingerScroll();
|
|
void fingerScrollSlow();
|
|
+ void continuousScroll();
|
|
void wheelDiscreteScroll();
|
|
|
|
// Touch tests
|
|
@@ -252,7 +253,7 @@
|
|
QCOMPARE(e.phase, Qt::ScrollUpdate);
|
|
QVERIFY(qAbs(e.angleDelta.x()) <= qAbs(e.angleDelta.y())); // Vertical scroll
|
|
// QCOMPARE(e.angleDelta, angleDelta); // TODO: what should this be?
|
|
- QCOMPARE(e.pixelDelta, QPoint(0, 10));
|
|
+ QCOMPARE(e.pixelDelta, QPoint(0, -10));
|
|
QCOMPARE(e.source, Qt::MouseEventSynthesizedBySystem); // A finger is not a wheel
|
|
}
|
|
|
|
@@ -269,7 +270,7 @@
|
|
auto e = window.m_events.takeFirst();
|
|
QCOMPARE(e.phase, Qt::ScrollUpdate);
|
|
QVERIFY(qAbs(e.angleDelta.x()) > qAbs(e.angleDelta.y())); // Horizontal scroll
|
|
- QCOMPARE(e.pixelDelta, QPoint(10, 0));
|
|
+ QCOMPARE(e.pixelDelta, QPoint(-10, 0));
|
|
QCOMPARE(e.source, Qt::MouseEventSynthesizedBySystem); // A finger is not a wheel
|
|
}
|
|
|
|
@@ -284,7 +285,7 @@
|
|
{
|
|
auto e = window.m_events.takeFirst();
|
|
QCOMPARE(e.phase, Qt::ScrollUpdate);
|
|
- QCOMPARE(e.pixelDelta, QPoint(10, 10));
|
|
+ QCOMPARE(e.pixelDelta, QPoint(-10, -10));
|
|
QCOMPARE(e.source, Qt::MouseEventSynthesizedBySystem); // A finger is not a wheel
|
|
}
|
|
|
|
@@ -338,7 +339,7 @@
|
|
accumulated += e.pixelDelta;
|
|
QTRY_VERIFY(!window.m_events.empty());
|
|
}
|
|
- QCOMPARE(accumulated.y(), 1);
|
|
+ QCOMPARE(accumulated.y(), -1);
|
|
}
|
|
void tst_seatv5::wheelDiscreteScroll()
|
|
{
|
|
@@ -370,6 +371,32 @@
|
|
}
|
|
}
|
|
|
|
+void tst_seatv5::continuousScroll()
|
|
+{
|
|
+ WheelWindow window;
|
|
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
|
+
|
|
+ exec([=] {
|
|
+ auto *p = pointer();
|
|
+ auto *c = client();
|
|
+ p->sendEnter(xdgToplevel()->surface(), {32, 32});
|
|
+ p->sendFrame(c);
|
|
+ p->sendAxisSource(c, Pointer::axis_source_continuous);
|
|
+ p->sendAxis(c, Pointer::axis_vertical_scroll, 10);
|
|
+ p->sendAxis(c, Pointer::axis_horizontal_scroll, -5);
|
|
+ p->sendFrame(c);
|
|
+ });
|
|
+
|
|
+ QTRY_VERIFY(!window.m_events.empty());
|
|
+ {
|
|
+ auto e = window.m_events.takeFirst();
|
|
+ QCOMPARE(e.phase, Qt::NoScrollPhase);
|
|
+ QCOMPARE(e.pixelDelta, QPoint(5, -10));
|
|
+ QCOMPARE(e.source, Qt::MouseEventSynthesizedBySystem); // touchpads are not wheels
|
|
+ }
|
|
+ // Sending axis_stop is not mandatory when axis source != finger
|
|
+}
|
|
+
|
|
void tst_seatv5::createsTouch()
|
|
{
|
|
QCOMPOSITOR_TRY_COMPARE(touch()->resourceMap().size(), 1);
|