SDL: Split the redraw effect to own function

From 4779499048c013b39c03c0803ccfed4381243049 Mon Sep 17 00:00:00 2001
From: expikr <[EMAIL REDACTED]>
Date: Mon, 28 Apr 2025 11:40:35 +0800
Subject: [PATCH] Split the redraw effect to own function

---
 src/events/SDL_mouse.c   | 34 +++++++++++++++++++++-------------
 src/events/SDL_mouse_c.h |  3 +++
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 2b5abf436fe68..80d9439e39863 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -1599,6 +1599,26 @@ SDL_Cursor *SDL_CreateSystemCursor(SDL_SystemCursor id)
     return cursor;
 }
 
+void SDL_RedrawCursor(void)
+{
+    SDL_Mouse *mouse = SDL_GetMouse();
+    SDL_Cursor *cursor;
+
+    if (mouse->focus) {
+        cursor = mouse->cur_cursor;
+    } else {
+        cursor = mouse->def_cursor;
+    }
+
+    if (mouse->focus && (!mouse->cursor_visible || (mouse->relative_mode && mouse->relative_mode_hide_cursor))) {
+        cursor = NULL;
+    }
+
+    if (mouse->ShowCursor) {
+        mouse->ShowCursor(cursor);
+    }
+}
+
 /* SDL_SetCursor(NULL) can be used to force the cursor redraw,
    if this is desired for any reason.  This is used when setting
    the video mode and when the SDL window gains the mouse focus.
@@ -1629,19 +1649,7 @@ bool SDL_SetCursor(SDL_Cursor *cursor)
         mouse->cur_cursor = cursor;
     }
 
-    if (mouse->focus) {
-        cursor = mouse->cur_cursor;
-    } else {
-        cursor = mouse->def_cursor;
-    }
-
-    if (mouse->focus && (!mouse->cursor_visible || (mouse->relative_mode && mouse->relative_mode_hide_cursor))) {
-        cursor = NULL;
-    }
-
-    if (mouse->ShowCursor) {
-        mouse->ShowCursor(cursor);
-    }
+    SDL_RedrawCursor();
 
     return true;
 }
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index 5acb48f3622a2..07a761b79789c 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -175,6 +175,9 @@ extern void SDL_SetMouseName(SDL_MouseID mouseID, const char *name);
 // Get the mouse state structure
 extern SDL_Mouse *SDL_GetMouse(void);
 
+// Set the default mouse cursor
+extern void SDL_RedrawCursor(void);
+
 // Set the default mouse cursor
 extern void SDL_SetDefaultCursor(SDL_Cursor *cursor);