[mutter] virtual-input-device/native: Emit discrete scroll when the source is a wheel



commit 92a90774a4ea0056be9ddcddccbcedc76fd52b2d
Author: José Expósito <jose exposito89 gmail com>
Date:   Sun Oct 16 18:33:37 2022 +0200

    virtual-input-device/native: Emit discrete scroll when the source is a wheel
    
    Previously, when scroll was received in a remote session, it was handled
    as continuous scroll.
    
    This generated issues with clients without high-resolution scroll
    support as the code path in charge of accumulating scroll until 120 is
    reached was not used and therefore discrete scroll events were not being
    generated.
    
    Handle scroll generated in a remote session as discrete scroll when the
    source is CLUTTER_SCROLL_SOURCE_WHEEL to fix this issue.
    
    Fix https://gitlab.gnome.org/GNOME/mutter/-/issues/2473
    
    Fixes: 9dd6268d13d5 ("wayland/pointer: Send high-resolution scroll data")
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2664>

 .../native/meta-virtual-input-device-native.c      | 25 ++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/backends/native/meta-virtual-input-device-native.c 
b/src/backends/native/meta-virtual-input-device-native.c
index 9fe77dfdcb..0e97b8fc64 100644
--- a/src/backends/native/meta-virtual-input-device-native.c
+++ b/src/backends/native/meta-virtual-input-device-native.c
@@ -743,12 +743,25 @@ notify_scroll_continuous_in_impl (GTask *task)
   if (event->time_us == CLUTTER_CURRENT_TIME)
     event->time_us = g_get_monotonic_time ();
 
-  meta_seat_impl_notify_scroll_continuous_in_impl (seat,
-                                                   virtual_evdev->impl_state->device,
-                                                   event->time_us,
-                                                   event->dx, event->dy,
-                                                   event->scroll_source,
-                                                   CLUTTER_SCROLL_FINISHED_NONE);
+  if (event->scroll_source == CLUTTER_SCROLL_SOURCE_WHEEL)
+    {
+      meta_seat_impl_notify_discrete_scroll_in_impl (seat,
+                                                     virtual_evdev->impl_state->device,
+                                                     event->time_us,
+                                                     event->dx * (120.0 / 10.0),
+                                                     event->dy * (120.0 / 10.0),
+                                                     event->scroll_source);
+    }
+  else
+    {
+      meta_seat_impl_notify_scroll_continuous_in_impl (seat,
+                                                       virtual_evdev->impl_state->device,
+                                                       event->time_us,
+                                                       event->dx, event->dy,
+                                                       event->scroll_source,
+                                                       CLUTTER_SCROLL_FINISHED_NONE);
+    }
+
   g_task_return_boolean (task, TRUE);
   return G_SOURCE_REMOVE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]