1
0
Fork 0

wayland: Avoid sending wl_pointer.motion on unchanged coordinates

This might happen for a variety of reasons, like monitor edges or
pointer constraints. Handle this naturally in MetaWaylandPointer for
all these cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
This commit is contained in:
Carlos Garnacho 2023-11-17 18:24:14 +01:00 committed by Robert Mader
parent 07d24fe502
commit 0e56ebb51a
2 changed files with 18 additions and 4 deletions

View file

@ -397,6 +397,9 @@ meta_wayland_pointer_send_motion (MetaWaylandPointer *pointer,
meta_wayland_surface_get_relative_coordinates (pointer->focus_surface,
x, y, &sx, &sy);
if (pointer->last_rel_x != sx ||
pointer->last_rel_y != sy)
{
wl_resource_for_each (resource, &pointer->focus_client->pointer_resources)
{
wl_pointer_send_motion (resource, time,
@ -404,6 +407,10 @@ meta_wayland_pointer_send_motion (MetaWaylandPointer *pointer,
wl_fixed_from_double (sy));
}
pointer->last_rel_x = sx;
pointer->last_rel_y = sy;
}
meta_wayland_pointer_send_relative_motion (pointer, event);
meta_wayland_pointer_broadcast_frame (pointer);
@ -469,6 +476,9 @@ meta_wayland_pointer_enable (MetaWaylandPointer *pointer)
"cursor-changed",
G_CALLBACK (meta_wayland_pointer_on_cursor_changed),
pointer);
pointer->last_rel_x = -FLT_MAX;
pointer->last_rel_y = -FLT_MAX;
}
void
@ -966,6 +976,9 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
if (pointer->focus_surface == surface)
return;
pointer->last_rel_x = -FLT_MAX;
pointer->last_rel_y = -FLT_MAX;
if (pointer->focus_surface != NULL)
{
uint32_t serial;

View file

@ -66,6 +66,7 @@ struct _MetaWaylandPointer
guint32 grab_serial;
guint32 grab_time;
float grab_x, grab_y;
float last_rel_x, last_rel_y;
ClutterInputDevice *device;
MetaWaylandSurface *current;