From 83ebf679b506901d1df58c4988b3cad19f3e3cdd Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Fri, 29 May 2026 22:05:22 -0300 Subject: [PATCH] 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. --- src/modules/window/sdl/Window.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 71c521c61..1104ea392 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -853,7 +853,6 @@ bool Window::setFullscreen(bool fullscreen, FullscreenType fstype) newsettings.fullscreen = fullscreen; newsettings.fstype = fstype; - bool sdlflags = fullscreen; if (fullscreen) { if (fstype == FULLSCREEN_DESKTOP) @@ -861,9 +860,11 @@ bool Window::setFullscreen(bool fullscreen, FullscreenType fstype) else { SDL_DisplayID displayid = SDL_GetDisplayForWindow(window); - SDL_DisplayMode mode = {}; - if (SDL_GetClosestFullscreenDisplayMode(displayid, windowWidth, windowHeight, 0, isHighDPIAllowed(), &mode)) - SDL_SetWindowFullscreenMode(window, &mode); + const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(displayid); + if (mode != nullptr) + SDL_SetWindowFullscreenMode(window, mode); + else + return false; } } @@ -871,7 +872,7 @@ bool Window::setFullscreen(bool fullscreen, FullscreenType fstype) love::android::setImmersive(fullscreen); #endif - if (SDL_SetWindowFullscreen(window, sdlflags)) + if (SDL_SetWindowFullscreen(window, fullscreen)) { if (glcontext) SDL_GL_MakeCurrent(window, glcontext);