1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
From 51b08756b48c295e0a136b26fd3c2d2b32e5e620 Mon Sep 17 00:00:00 2001
From: Cedric CHEDALEUX <cedric.chedaleux@orange.com>
Date: Thu, 3 Jul 2025 22:57:45 +0200
Subject: [PATCH] cursor: fix scroll issues
InputEventDispatcher filters the MouseEvent coming from the underlying Mir stack
to adjust the position of the cursor in Lomiri system. Lomiri cursor
position depends on the screen(s) configuration (virtual touch pad on phone screen,
oriented shell, center reset position). The cursor bounds are also
different from the screen geometry to trigger gestures.
Only Mouse events (MouseMove, MouseButtons) are adjusted so far. The wheel
events are propagated up to the top window and QML items and they
still hold a global position of Mir and not the adjusted Lomiri one.
Let's also adjust the position for WheelEvent.
Bug: https://salsa.debian.org/ubports-team/qtmir/-/issues/6
Signed-off-by: Cedric CHEDALEUX <cedric.chedaleux@orange.com>
---
plugins/Cursor/InputDispatcherFilter.cpp | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
--- a/plugins/Cursor/InputDispatcherFilter.cpp
+++ b/plugins/Cursor/InputDispatcherFilter.cpp
@@ -127,6 +127,28 @@
o->event(&eCopy);
return true;
}
+ // Adjust position for Wheel event the same way as mouse events
+ case QEvent::Wheel:
+ {
+ // if we don't have any pointers, filter all mouse events.
+ auto pointer = currentPointer();
+ if (!pointer || !pointer->window()) return true;
+
+ QWheelEvent* we = static_cast<QWheelEvent*>(e);
+
+ // Local position gives relative change of mouse pointer.
+ QPointF movement = we->position();
+
+ // Adjust the position
+ QPointF oldPos = pointer->window()->geometry().topLeft() + pointer->position();
+ QPointF newPos = adjustedPositionForMovement(oldPos, movement);
+
+ // Send the event
+ QWheelEvent eCopy(we->position(), newPos, we->pixelDelta(), we->angleDelta(), we->buttons(), we->modifiers(), we->phase(), we->inverted());
+ eCopy.setTimestamp(we->timestamp());
+ o->event(&eCopy);
+ return true;
+ }
default:
break;
}
|