1
0
Fork 0

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;
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;
}