Skip to content

Commit

Permalink
Added fullscreen_active to better track fullscreen state
Browse files Browse the repository at this point in the history
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 7c29c8b)
  • Loading branch information
slouken committed Mar 4, 2025
1 parent 1d6bb62 commit 5a7b17f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/video/SDL_sysvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/video/SDL_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5a7b17f

Please sign in to comment.