X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=74123228f2b2185f43100f4c3b2d5c19b70f356a;hp=95ef6eef6e9d97dcf3f724c45a1febc7af3d2022;hb=80b3b0a5109b5678a9a921fcd1b4f7046e5e76d0;hpb=9028fc1280e47a368d8778157403b4216a89e036 diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 95ef6eef..74123228 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1277,19 +1277,26 @@ static SDL_Cursor *create_cursor(struct MouseCursorInfo *cursor_info) void SDLSetMouseCursor(struct MouseCursorInfo *cursor_info) { static struct MouseCursorInfo *last_cursor_info = NULL; + static struct MouseCursorInfo *last_cursor_info2 = NULL; static SDL_Cursor *cursor_default = NULL; static SDL_Cursor *cursor_current = NULL; + /* if invoked for the first time, store the SDL default cursor */ if (cursor_default == NULL) cursor_default = SDL_GetCursor(); + /* only create new cursor if cursor info (custom only) has changed */ if (cursor_info != NULL && cursor_info != last_cursor_info) { cursor_current = create_cursor(cursor_info); last_cursor_info = cursor_info; } - SDL_SetCursor(cursor_info ? cursor_current : cursor_default); + /* only set new cursor if cursor info (custom or NULL) has changed */ + if (cursor_info != last_cursor_info2) + SDL_SetCursor(cursor_info ? cursor_current : cursor_default); + + last_cursor_info2 = cursor_info; }