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 5617ce277d)
This commit is contained in:
Frank Praznik 2024-07-27 20:22:10 -04:00
parent 50a6a39dd6
commit 5d1ca1c8c7
No known key found for this signature in database
1 changed files with 10 additions and 10 deletions

View File

@ -194,7 +194,6 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
int size = 0; int size = 0;
SDL_Window *focus; SDL_Window *focus;
SDL_WindowData *focusdata;
int i; int i;
/* /*
@ -218,16 +217,17 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa
} }
/* First, find the appropriate theme based on the current scale... */ /* First, find the appropriate theme based on the current scale... */
focus = SDL_GetMouse()->focus; focus = SDL_GetMouse()->focus;
if (!focus) { if (focus) {
/* Nothing to see here, bail. */ SDL_WindowData *focusdata = (SDL_WindowData*)focus->driverdata;
return SDL_FALSE;
}
focusdata = focus->driverdata;
/* Cursors use integer scaling. */ /* Cursors use integer scaling. */
*scale = SDL_ceilf(focusdata->scale_factor); *scale = SDL_ceilf(focusdata->scale_factor);
size *= *scale; } else {
for (i = 0; i < vdata->num_cursor_themes; i += 1) { *scale = 1.0f;
}
size *= (int)*scale;
for (i = 0; i < vdata->num_cursor_themes; ++i) {
if (vdata->cursor_themes[i].size == size) { if (vdata->cursor_themes[i].size == size) {
theme = vdata->cursor_themes[i].theme; theme = vdata->cursor_themes[i].theme;
break; break;