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.
This commit is contained in:
Cameron Gutman 2021-01-20 23:19:24 -06:00
parent bf53651d73
commit cf84ec441f
1 changed files with 4 additions and 0 deletions

View File

@ -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);
}
}