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.
This commit is contained in:
Sam Lantinga 2025-03-03 16:23:29 -08:00
parent 3b9f0dff10
commit 7c29c8b266
2 changed files with 8 additions and 1 deletions

View File

@ -163,6 +163,8 @@ struct SDL_VideoDisplay
float content_scale; float content_scale;
SDL_HDROutputProperties HDR; SDL_HDROutputProperties HDR;
// This is true if we are fullscreen or fullscreen is pending
bool fullscreen_active;
SDL_Window *fullscreen_window; SDL_Window *fullscreen_window;
SDL_VideoDevice *device; SDL_VideoDevice *device;

View File

@ -1435,7 +1435,7 @@ void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode
{ {
SDL_DisplayMode last_mode; 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 // This is a temporary mode change, don't save the desktop mode
return; return;
} }
@ -1949,6 +1949,8 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
SDL_MinimizeWindow(display->fullscreen_window); SDL_MinimizeWindow(display->fullscreen_window);
} }
display->fullscreen_active = window->fullscreen_exclusive;
if (!SDL_SetDisplayModeForDisplay(display, mode)) { if (!SDL_SetDisplayModeForDisplay(display, mode)) {
goto error; 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); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0);
} }
} else if (ret == SDL_FULLSCREEN_FAILED) { } else if (ret == SDL_FULLSCREEN_FAILED) {
display->fullscreen_active = false;
goto error; goto error;
} }
} }
@ -2010,6 +2013,8 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
// Restore the desktop mode // Restore the desktop mode
if (display) { if (display) {
display->fullscreen_active = false;
SDL_SetDisplayModeForDisplay(display, NULL); SDL_SetDisplayModeForDisplay(display, NULL);
} }
if (commit) { if (commit) {