From 5a7b17fec591a2ed0587449da79429e571f5abc0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 3 Mar 2025 16:23:29 -0800
Subject: [PATCH] Added fullscreen_active to better track fullscreen state
This is true if fullscreen is pending or currently active. This is a better check in SDL_SetDesktopDisplayMode() because a fullscreen mode may be pending and complete asynchronously and the window hasn't been set to fullscreen yet.
(cherry picked from commit 7c29c8b266091dab81ae3929d7f72cdb94bcb27d)
---
src/video/SDL_sysvideo.h | 2 ++
src/video/SDL_video.c | 7 ++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 6951d456424ae..6da8bd2e1853e 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -163,6 +163,8 @@ struct SDL_VideoDisplay
float content_scale;
SDL_HDROutputProperties HDR;
+ // This is true if we are fullscreen or fullscreen is pending
+ bool fullscreen_active;
SDL_Window *fullscreen_window;
SDL_VideoDevice *device;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 5d235a50cbd99..d8f4535664d4b 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1435,7 +1435,7 @@ void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode
{
SDL_DisplayMode last_mode;
- if (display->fullscreen_window || _this->setting_display_mode) {
+ if (display->fullscreen_active) {
// This is a temporary mode change, don't save the desktop mode
return;
}
@@ -1949,6 +1949,8 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
SDL_MinimizeWindow(display->fullscreen_window);
}
+ display->fullscreen_active = window->fullscreen_exclusive;
+
if (!SDL_SetDisplayModeForDisplay(display, mode)) {
goto error;
}
@@ -1966,6 +1968,7 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0);
}
} else if (ret == SDL_FULLSCREEN_FAILED) {
+ display->fullscreen_active = false;
goto error;
}
}
@@ -2010,6 +2013,8 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
// Restore the desktop mode
if (display) {
+ display->fullscreen_active = false;
+
SDL_SetDisplayModeForDisplay(display, NULL);
}
if (commit) {