Browse Source

x11: Track cursor visibility internally

Cursor visibility in the SDL input layer only reflects whether ShowCursor/HideCursor was called. In the case of relative mode, the cursor can be hidden, but the SDL_Mouse visibility flag will be true.

Track cursor visibility separately in the X11 driver. Fixes the cursor becoming visible when using the warping relative mode with XWayland.
Frank Praznik 9 months ago
parent
commit
b0713a7d30
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/video/x11/SDL_x11mouse.c

+ 4 - 2
src/video/x11/SDL_x11mouse.c

@@ -31,6 +31,7 @@
 
 /* FIXME: Find a better place to put this... */
 static Cursor x11_empty_cursor = None;
+static SDL_bool x11_cursor_visible = SDL_TRUE;
 
 static SDL_Cursor *sys_cursors[SDL_HITTEST_RESIZE_LEFT + 1];
 
@@ -296,6 +297,8 @@ static int X11_ShowCursor(SDL_Cursor *cursor)
         Display *display = GetDisplay();
         SDL_Window *window;
 
+        x11_cursor_visible = !!cursor;
+
         for (window = video->windows; window; window = window->next) {
             SDL_WindowData *data = window->internal;
             if (data) {
@@ -315,11 +318,10 @@ static void X11_WarpMouseInternal(Window xwindow, float x, float y)
 {
     SDL_VideoData *videodata = SDL_GetVideoDevice()->internal;
     Display *display = videodata->display;
-    SDL_Mouse *mouse = SDL_GetMouse();
     SDL_bool warp_hack = SDL_FALSE;
 
     /* XWayland will only warp the cursor if it is hidden, so this workaround is required. */
-    if (videodata->is_xwayland && mouse && mouse->cursor_shown) {
+    if (videodata->is_xwayland && x11_cursor_visible) {
         warp_hack = SDL_TRUE;
     }