SDL: SDL_UpdateFullscreenMode: Only restore mouse position when exiting fullscreen if the fullscreen mode actually changed

From 8d9c7d8ebe2a425ed0becb84bef20a955bb9c6ac Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 19 Jan 2024 15:26:46 -0800
Subject: [PATCH] SDL_UpdateFullscreenMode: Only restore mouse position when
 exiting fullscreen if the fullscreen mode actually changed

- Previously we would skip most of UpdateFullscreenMode if not entering fullscreen and the window was not set as fullscreen for any display
  which prevented running this.

This prevents warping the mouse when hiding a non-fullscreen window
---
 src/video/SDL_video.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 1aa3c0d23aaf..dc36afab2c75 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1745,8 +1745,10 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen, SDL_bool c
                 }
             }
 
-            /* Restore the cursor position */
-            SDL_RestoreMousePosition(window);
+            /* Restore the cursor position if we've exited fullscreen on a display */
+            if (display) {
+                SDL_RestoreMousePosition(window);
+            }
         }
     }