Skip to content

Commit

Permalink
wayland: Don't fail to retrieve a system cursor if no window is focused
Browse files Browse the repository at this point in the history
Doing this can leave the cursor data in a weird, corrupt state.

(cherry picked from commit 5617ce2)
(cherry picked from commit 5d1ca1c)
  • Loading branch information
Kontrabant committed Jul 28, 2024
1 parent 0406d1c commit 881c4cb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/video/wayland/SDL_waylandmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand All @@ -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;
Expand Down

0 comments on commit 881c4cb

Please sign in to comment.