From cf84ec441f8192ee50ae2aa8c6f8bf70c3bb91ca Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 20 Jan 2021 23:19:24 -0600 Subject: [PATCH] Improve reliability of cursor hiding on GNOME Wayland Hiding the cursor doesn't appear to work reliably on GNOME when another window steals mouse focus right as we call SDL_ShowCursor(SDL_DISABLE). This can happen when the keyboard shortcut inhibition permission prompt appears in response to a call to SDL_SetRelativeMouseMode() with SDL_HINT_GRAB_KEYBOARD=1. The result is that the default cursor is stuck locked in position and visible on screen indefinitely. By redrawing the cursor on pointer focus enter, the cursor now disappears upon the first mouse motion event. It's not perfect but it's way better than the current behavior. --- src/video/wayland/SDL_waylandevents.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 0030166f0..0c127c8c7 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -326,6 +326,10 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, * event with no following motion event, but with the new coordinates * as part of the enter event. */ pointer_handle_motion(data, pointer, serial, sx_w, sy_w); + /* If the cursor was changed while our window didn't have pointer + * focus, we might need to trigger another call to + * wl_pointer_set_cursor() for the new cursor to be displayed. */ + SDL_SetCursor(NULL); } }