From 92a90774a4ea0056be9ddcddccbcedc76fd52b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Sun, 16 Oct 2022 18:33:37 +0200 Subject: [PATCH] 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: --- .../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 9fe77dfdc..0e97b8fc6 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; }