mirror of
https://github.com/brl/mutter.git
synced 2025-02-08 17:44:09 +00:00
wayland: Filter scroll events based on source
The POINTER_EMULATED flag was a convenience to filter either side of smooth/discrete events that we should ignore based on the source. This distinction was challenged, first by v120 mice that use Clutter smooth events to deliver semi-discrete changes, second by commit e0c4b2b241 ("backends/native: Mark the emulated smooth scroll event as such") which made the smooth events be flagged as emulated, and the discrete whole-step events marked as real. This distinction feels convenient for the time being, since upper layers might be confused by real smooth scroll events without finish flags. Adapt to this change at MetaWaylandPointer so that we drop the POINTER_EMULATED check, and the events are perhaps filtered based on their source and the preferred wl_seat version of the client that we are talking to. This handles the whole grid of combinations: - wheel sources with wl_seat >=8 result in wl_pointer.axis_value120 from "emulated" smooth scroll events, with value120 information. - wheel sources with wl_seat < 8 result in wl_pointer.axis_discrete from "real" discrete scroll events. - finger/continuous sources prefer smooth events. Previously, always non-emulated for those. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
This commit is contained in:
parent
39d8e44f5e
commit
ab8e145e25
@ -706,6 +706,34 @@ handle_button_event (MetaWaylandPointer *pointer,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
maybe_filter_scroll_event (const ClutterEvent *event,
|
||||
int client_version)
|
||||
{
|
||||
ClutterScrollSource source;
|
||||
|
||||
source = clutter_event_get_scroll_source (event);
|
||||
|
||||
switch (clutter_event_get_scroll_direction (event))
|
||||
{
|
||||
case CLUTTER_SCROLL_UP:
|
||||
case CLUTTER_SCROLL_DOWN:
|
||||
case CLUTTER_SCROLL_LEFT:
|
||||
case CLUTTER_SCROLL_RIGHT:
|
||||
if (source == CLUTTER_SCROLL_SOURCE_WHEEL)
|
||||
return client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION;
|
||||
|
||||
return TRUE;
|
||||
case CLUTTER_SCROLL_SMOOTH:
|
||||
if (source == CLUTTER_SCROLL_SOURCE_WHEEL)
|
||||
return client_version < WL_POINTER_AXIS_VALUE120_SINCE_VERSION;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_scroll_event (MetaWaylandPointer *pointer,
|
||||
const ClutterEvent *event)
|
||||
@ -718,9 +746,6 @@ handle_scroll_event (MetaWaylandPointer *pointer,
|
||||
MetaWaylandPointerClient *client;
|
||||
ClutterScrollFinishFlags finish_flags;
|
||||
|
||||
if (clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_POINTER_EMULATED)
|
||||
return;
|
||||
|
||||
client = pointer->focus_client;
|
||||
if (!client)
|
||||
return;
|
||||
@ -796,6 +821,9 @@ handle_scroll_event (MetaWaylandPointer *pointer,
|
||||
{
|
||||
int client_version = wl_resource_get_version (resource);
|
||||
|
||||
if (maybe_filter_scroll_event (event, client_version))
|
||||
continue;
|
||||
|
||||
if (client_version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION)
|
||||
wl_pointer_send_axis_source (resource, source);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user