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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
This commit is contained in:
Carlos Garnacho 2024-03-05 13:30:24 +01:00 committed by Marge Bot
parent 7aebc9e63d
commit ddc76d878e

View File

@ -748,24 +748,28 @@ handle_scroll_event (MetaWaylandPointer *pointer,
is_discrete_event = TRUE; is_discrete_event = TRUE;
y_value = -DEFAULT_AXIS_STEP_DISTANCE; y_value = -DEFAULT_AXIS_STEP_DISTANCE;
y_discrete = -1; y_discrete = -1;
y_value120 = y_discrete * 120;
break; break;
case CLUTTER_SCROLL_DOWN: case CLUTTER_SCROLL_DOWN:
is_discrete_event = TRUE; is_discrete_event = TRUE;
y_value = DEFAULT_AXIS_STEP_DISTANCE; y_value = DEFAULT_AXIS_STEP_DISTANCE;
y_discrete = 1; y_discrete = 1;
y_value120 = y_discrete * 120;
break; break;
case CLUTTER_SCROLL_LEFT: case CLUTTER_SCROLL_LEFT:
is_discrete_event = TRUE; is_discrete_event = TRUE;
x_value = -DEFAULT_AXIS_STEP_DISTANCE; x_value = -DEFAULT_AXIS_STEP_DISTANCE;
x_discrete = -1; x_discrete = -1;
x_value120 = x_discrete * 120;
break; break;
case CLUTTER_SCROLL_RIGHT: case CLUTTER_SCROLL_RIGHT:
is_discrete_event = TRUE; is_discrete_event = TRUE;
x_value = DEFAULT_AXIS_STEP_DISTANCE; x_value = DEFAULT_AXIS_STEP_DISTANCE;
x_discrete = 1; x_discrete = 1;
x_value120 = x_discrete * 120;
break; break;
case CLUTTER_SCROLL_SMOOTH: case CLUTTER_SCROLL_SMOOTH:
@ -805,19 +809,23 @@ handle_scroll_event (MetaWaylandPointer *pointer,
/* X axis */ /* X axis */
if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
{ {
if (is_value120_event && x_value120 != 0) if (x_value120 != 0)
{
wl_pointer_send_axis_value120 (resource, wl_pointer_send_axis_value120 (resource,
WL_POINTER_AXIS_HORIZONTAL_SCROLL, WL_POINTER_AXIS_HORIZONTAL_SCROLL,
x_value120); x_value120);
}
send_axis_x = !is_discrete_event; send_axis_x = !is_discrete_event;
} }
else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
{ {
if (is_discrete_event && x_discrete != 0) if (x_discrete != 0)
{
wl_pointer_send_axis_discrete (resource, wl_pointer_send_axis_discrete (resource,
WL_POINTER_AXIS_HORIZONTAL_SCROLL, WL_POINTER_AXIS_HORIZONTAL_SCROLL,
x_discrete); x_discrete);
}
send_axis_x = !is_value120_event; send_axis_x = !is_value120_event;
} }
@ -834,19 +842,23 @@ handle_scroll_event (MetaWaylandPointer *pointer,
/* Y axis */ /* Y axis */
if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION) if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
{ {
if (is_value120_event && y_value120 != 0) if (y_value120 != 0)
{
wl_pointer_send_axis_value120 (resource, wl_pointer_send_axis_value120 (resource,
WL_POINTER_AXIS_VERTICAL_SCROLL, WL_POINTER_AXIS_VERTICAL_SCROLL,
y_value120); y_value120);
}
send_axis_y = !is_discrete_event; send_axis_y = !is_discrete_event;
} }
else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION) else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
{ {
if (is_discrete_event && y_discrete != 0) if (y_discrete != 0)
{
wl_pointer_send_axis_discrete (resource, wl_pointer_send_axis_discrete (resource,
WL_POINTER_AXIS_VERTICAL_SCROLL, WL_POINTER_AXIS_VERTICAL_SCROLL,
y_discrete); y_discrete);
}
send_axis_y = !is_value120_event; send_axis_y = !is_value120_event;
} }