Only update the window size if setting the display mode succeeded
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 25b8aeb..ec6dc08 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1162,12 +1162,15 @@ SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
- SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode);
- /* make sure the window size (and internals like window-surface size) are adjusted */
- if (window->w != fullscreen_mode.w || window->h != fullscreen_mode.h) {
- window->w = fullscreen_mode.w;
- window->h = fullscreen_mode.h;
- SDL_OnWindowResized(window);
+ if (SDL_SetDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode) == 0) {
+#ifndef ANDROID
+ /* Android may not resize the window to exactly what our fullscreen mode is, especially on
+ * windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
+ * use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
+ * Android's SetWindowFullscreen will generate the window event for us with the proper final size.
+ */
+ SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED, fullscreen_mode.w, fullscreen_mode.h);
+#endif
}
}
}
@@ -1364,11 +1367,11 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
/* Generate a mode change event here */
if (resized) {
#ifndef ANDROID
- // Android may not resize the window to exactly what our fullscreen mode is, especially on
- // windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
- // use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
- // Android's SetWindowFullscreen will generate the window event for us with the proper final size.
-
+ /* Android may not resize the window to exactly what our fullscreen mode is, especially on
+ * windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
+ * use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
+ * Android's SetWindowFullscreen will generate the window event for us with the proper final size.
+ */
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
fullscreen_mode.w, fullscreen_mode.h);
#endif