Skip to content

Commit 83ebf67

Browse files
committed
love.window.setFullscreen(true, "exclusive") always uses the desktop's display mode.
This avoids switching the display mode when toggling fullscreen or alt-tabbing, after toggling fullscreen.
1 parent 06e8da7 commit 83ebf67

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/modules/window/sdl/Window.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,25 +853,26 @@ bool Window::setFullscreen(bool fullscreen, FullscreenType fstype)
853853
newsettings.fullscreen = fullscreen;
854854
newsettings.fstype = fstype;
855855

856-
bool sdlflags = fullscreen;
857856
if (fullscreen)
858857
{
859858
if (fstype == FULLSCREEN_DESKTOP)
860859
SDL_SetWindowFullscreenMode(window, nullptr);
861860
else
862861
{
863862
SDL_DisplayID displayid = SDL_GetDisplayForWindow(window);
864-
SDL_DisplayMode mode = {};
865-
if (SDL_GetClosestFullscreenDisplayMode(displayid, windowWidth, windowHeight, 0, isHighDPIAllowed(), &mode))
866-
SDL_SetWindowFullscreenMode(window, &mode);
863+
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(displayid);
864+
if (mode != nullptr)
865+
SDL_SetWindowFullscreenMode(window, mode);
866+
else
867+
return false;
867868
}
868869
}
869870

870871
#ifdef LOVE_ANDROID
871872
love::android::setImmersive(fullscreen);
872873
#endif
873874

874-
if (SDL_SetWindowFullscreen(window, sdlflags))
875+
if (SDL_SetWindowFullscreen(window, fullscreen))
875876
{
876877
if (glcontext)
877878
SDL_GL_MakeCurrent(window, glcontext);

0 commit comments

Comments
 (0)