SDL: wayland: Don't fail to retrieve a system cursor if no window is focused (881c4)

From 881c4cb49eb2d67b761f1ab6d88e2d83294bd1a5 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sat, 27 Jul 2024 20:22:10 -0400
Subject: [PATCH] wayland: Don't fail to retrieve a system cursor if no window
 is focused

Doing this can leave the cursor data in a weird, corrupt state.

(cherry picked from commit 5617ce277d1f85d831e9d50673dcece91488616b)
(cherry picked from commit 5d1ca1c8c744c51c1d4046b8a10d37f2aea79d0b)
---
 src/video/wayland/SDL_waylandmouse.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c
index 4b7264588dd0b..18550171dcddd 100644
--- a/src/video/wayland/SDL_waylandmouse.c
+++ b/src/video/wayland/SDL_waylandmouse.c
@@ -192,7 +192,6 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
     int size = 0;
 
     SDL_Window *focus;
-    SDL_WindowData *focusdata;
     int i;
 
     /*
@@ -216,16 +215,17 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
     }
     /* First, find the appropriate theme based on the current scale... */
     focus = SDL_GetMouse()->focus;
-    if (!focus) {
-        /* Nothing to see here, bail. */
-        return SDL_FALSE;
+    if (focus) {
+        SDL_WindowData *focusdata = (SDL_WindowData*)focus->driverdata;
+
+        /* Cursors use integer scaling. */
+        *scale = SDL_ceilf(focusdata->scale_factor);
+    } else {
+        *scale = 1.0f;
     }
-    focusdata = focus->driverdata;
 
-    /* Cursors use integer scaling. */
-    *scale = SDL_ceilf(focusdata->scale_factor);
-    size *= *scale;
-    for (i = 0; i < vdata->num_cursor_themes; i += 1) {
+    size *= (int)*scale;
+    for (i = 0; i < vdata->num_cursor_themes; ++i) {
         if (vdata->cursor_themes[i].size == size) {
             theme = vdata->cursor_themes[i].theme;
             break;