libweston-desktop: Prevent spurious focus change signals

This should prevent extra focus signal emission the similarly to
how default_grab_pointer_focus() does, though we don't have the
surface jumping logic here.

This stops xdg pings from being sent every output repaint during
a grab when the pointer isn't in any windows belonging to the
grab parent.

An example would be running weston-terminal, bringing up the
right click pop-up, and moving the mouse onto the desktop while
another client causes repaints.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-08-29 15:09:42 -05:00
parent 58de1aac5c
commit ef4d2955f0

View File

@ -99,9 +99,16 @@ weston_desktop_seat_popup_grab_pointer_focus(struct weston_pointer_grab *grab)
view = weston_compositor_pick_view(pointer->seat->compositor,
pointer->x, pointer->y);
/* Ignore views that don't belong to the grabbing client */
if (view != NULL &&
view->surface->resource != NULL &&
wl_resource_get_client(view->surface->resource) == seat->popup_grab.client)
wl_resource_get_client(view->surface->resource) != seat->popup_grab.client)
view = NULL;
if (pointer->focus == view)
return;
if (view)
weston_pointer_set_focus(pointer, view);
else
weston_pointer_clear_focus(pointer);