wayland: Do not query seat for pointer coordinates

In the wayland code we are in synchronization with the events that
the ClutterStage is managing at the moment. Asking the ClutterSeat for
the pointer position gets ahead of the current events, and may result
in imprecise coordinates sent in wl_pointer.enter.

To be in consistence with the motion events that might be already
queued, we should ask the stage for the last known coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
This commit is contained in:
Carlos Garnacho 2020-12-22 17:33:03 +01:00
parent 0021fe173b
commit 1f17a7ffef

View File

@ -908,6 +908,7 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
if (surface != NULL) if (surface != NULL)
{ {
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
struct wl_client *client = wl_resource_get_client (surface->resource); struct wl_client *client = wl_resource_get_client (surface->resource);
graphene_point_t pos; graphene_point_t pos;
MetaWindow *focus_window; MetaWindow *focus_window;
@ -919,8 +920,7 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
G_CALLBACK (focus_surface_destroyed), G_CALLBACK (focus_surface_destroyed),
pointer); pointer);
clutter_seat_query_state (clutter_input_device_get_seat (pointer->device), clutter_stage_get_device_coords (stage, pointer->device, NULL, &pos);
pointer->device, NULL, &pos, NULL);
focus_window = meta_wayland_surface_get_window (pointer->focus_surface); focus_window = meta_wayland_surface_get_window (pointer->focus_surface);
if (focus_window) if (focus_window)
@ -1042,11 +1042,12 @@ meta_wayland_pointer_get_relative_coordinates (MetaWaylandPointer *pointer,
wl_fixed_t *sx, wl_fixed_t *sx,
wl_fixed_t *sy) wl_fixed_t *sy)
{ {
MetaBackend *backend = meta_get_backend ();
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
float xf = 0.0f, yf = 0.0f; float xf = 0.0f, yf = 0.0f;
graphene_point_t pos; graphene_point_t pos;
clutter_seat_query_state (clutter_input_device_get_seat (pointer->device), clutter_stage_get_device_coords (stage, pointer->device, NULL, &pos);
pointer->device, NULL, &pos, NULL);
meta_wayland_surface_get_relative_coordinates (surface, pos.x, pos.y, &xf, &yf); meta_wayland_surface_get_relative_coordinates (surface, pos.x, pos.y, &xf, &yf);
*sx = wl_fixed_from_double (xf); *sx = wl_fixed_from_double (xf);