SDL: video: Only sync when programmatically entering/exiting fullscreen

From 835c733f4d2199b4b9f195f0d1c4b9286726e071 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 12 Dec 2023 12:58:05 -0500
Subject: [PATCH] video: Only sync when programmatically entering/exiting
 fullscreen

Otherwise, the sync function can be recursively entered when the fullscreen state is updated by a window manager event.
---
 src/video/SDL_video.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 03ad6ffe0929..ecf909568acd 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1754,7 +1754,6 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen, SDL_bool c
 
 done:
     window->last_fullscreen_exclusive_display = display && (window->flags & SDL_WINDOW_FULLSCREEN) && window->fullscreen_exclusive ? display->id : 0;
-    SDL_SyncIfRequired(window);
     return 0;
 
 error:
@@ -2974,6 +2973,10 @@ int SDL_SetWindowFullscreen(SDL_Window *window, SDL_bool fullscreen)
         SDL_zero(window->current_fullscreen_mode);
     }
 
+    if (ret == 0) {
+        SDL_SyncIfRequired(window);
+    }
+
     return ret;
 }