Browse Source

video: Don't resize moved fullscreen windows if the display mode switch failed

If an exclusive fullscreen window is moved between displays, SDL_UpdateFullscrrenMode can kick the window out of fullscreen if the display onto which it was moved doesn't have a matching video mode. Check the return code and clear the fullscreen flag and skip the resize if the window is no longer fullscreen.
Frank Praznik 2 years ago
parent
commit
34bb0735d8
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/video/SDL_video.c

+ 6 - 1
src/video/SDL_video.c

@@ -2930,7 +2930,12 @@ void SDL_OnWindowDisplayChanged(SDL_Window *window)
 
         if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
             window->last_fullscreen_flags = 0;
-            SDL_UpdateFullscreenMode(window, SDL_TRUE);
+
+            if (SDL_UpdateFullscreenMode(window, SDL_TRUE) != 0) {
+                /* Something went wrong and the window is no longer fullscreen. */
+                window->flags &= ~FULLSCREEN_MASK;
+                return;
+            }
         }
 
         /*