From ddc76d878e937665f90a9a35c87229f9711a91b8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Mar 2024 13:30:24 +0100 Subject: [PATCH] wayland: Fix handling of non-v120 discrete events on wl_seat >= v8 Unveiled by commit e0c4b2b241 ("backends/native: Mark the emulated smooth scroll event as such"). The sudden "lack" of smooth scroll events (Used by Clutter to forward v120 events) made it evident we silently ignore Clutter discrete events, as we don't send wl_pointer.axis_value120 for these. Fix this by assigning a value120 value to discrete scroll events. This makes wl_pointer.axis_value120 events actually sent on non-v120 mice. Part-of: --- src/wayland/meta-wayland-pointer.c | 44 +++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index bbff7e256..81db9e4f5 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -748,24 +748,28 @@ handle_scroll_event (MetaWaylandPointer *pointer, is_discrete_event = TRUE; y_value = -DEFAULT_AXIS_STEP_DISTANCE; y_discrete = -1; + y_value120 = y_discrete * 120; break; case CLUTTER_SCROLL_DOWN: is_discrete_event = TRUE; y_value = DEFAULT_AXIS_STEP_DISTANCE; y_discrete = 1; + y_value120 = y_discrete * 120; break; case CLUTTER_SCROLL_LEFT: is_discrete_event = TRUE; x_value = -DEFAULT_AXIS_STEP_DISTANCE; x_discrete = -1; + x_value120 = x_discrete * 120; break; case CLUTTER_SCROLL_RIGHT: is_discrete_event = TRUE; x_value = DEFAULT_AXIS_STEP_DISTANCE; x_discrete = 1; + x_value120 = x_discrete * 120; break; case CLUTTER_SCROLL_SMOOTH: @@ -805,19 +809,23 @@ handle_scroll_event (MetaWaylandPointer *pointer, /* X axis */ if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) { - if (is_value120_event && x_value120 != 0) - wl_pointer_send_axis_value120 (resource, - WL_POINTER_AXIS_HORIZONTAL_SCROLL, - x_value120); + if (x_value120 != 0) + { + wl_pointer_send_axis_value120 (resource, + WL_POINTER_AXIS_HORIZONTAL_SCROLL, + x_value120); + } send_axis_x = !is_discrete_event; } else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) { - if (is_discrete_event && x_discrete != 0) - wl_pointer_send_axis_discrete (resource, - WL_POINTER_AXIS_HORIZONTAL_SCROLL, - x_discrete); + if (x_discrete != 0) + { + wl_pointer_send_axis_discrete (resource, + WL_POINTER_AXIS_HORIZONTAL_SCROLL, + x_discrete); + } send_axis_x = !is_value120_event; } @@ -834,19 +842,23 @@ handle_scroll_event (MetaWaylandPointer *pointer, /* Y axis */ if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) { - if (is_value120_event && y_value120 != 0) - wl_pointer_send_axis_value120 (resource, - WL_POINTER_AXIS_VERTICAL_SCROLL, - y_value120); + if (y_value120 != 0) + { + wl_pointer_send_axis_value120 (resource, + WL_POINTER_AXIS_VERTICAL_SCROLL, + y_value120); + } send_axis_y = !is_discrete_event; } else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) { - if (is_discrete_event && y_discrete != 0) - wl_pointer_send_axis_discrete (resource, - WL_POINTER_AXIS_VERTICAL_SCROLL, - y_discrete); + if (y_discrete != 0) + { + wl_pointer_send_axis_discrete (resource, + WL_POINTER_AXIS_VERTICAL_SCROLL, + y_discrete); + } send_axis_y = !is_value120_event; }