From 9409ce70242a4775c058508285ff3a908743c7c9 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 28 Oct 2022 14:09:34 -0500 Subject: [PATCH] input: Don't test bogus coordinates in surface jump logic sx and sy are meaningless (-1000000) when view is NULL. The case this is meant to catch is when the surface coordinates change while the global coordinate doesn't, (eg: max/unmax a window with a keyboard shortcut) - in that case view will always be set. Signed-off-by: Derek Foreman --- libweston/input.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libweston/input.c b/libweston/input.c index f22d9809..ee68699d 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -456,6 +456,7 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab) struct weston_pointer *pointer = grab->pointer; struct weston_view *view; wl_fixed_t sx, sy; + bool surface_jump = false; if (pointer->button_count > 0) return; @@ -463,8 +464,12 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab) view = weston_compositor_pick_view(pointer->seat->compositor, pointer->x, pointer->y, &sx, &sy); + if (view) { + if (pointer->sx != sx || pointer->sy != sy) + surface_jump = true; + } - if (pointer->focus != view || pointer->sx != sx || pointer->sy != sy) + if (pointer->focus != view || surface_jump) weston_pointer_set_focus(pointer, view); } @@ -1458,7 +1463,7 @@ weston_pointer_set_focus(struct weston_pointer *pointer, if ((!pointer->focus && view) || (pointer->focus && !view) || (pointer->focus && pointer->focus->surface != view->surface) || - pointer->sx != sx || pointer->sy != sy) + (view && (pointer->sx != sx || pointer->sy != sy))) refocus = 1; if (pointer->focus_client && refocus) {