From 994dc04a8513f374e47dae37ab301966d8ce4e39 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sat, 18 Apr 2026 20:05:57 +0200 Subject: [PATCH] BACKENDS: OPENGLSDL: Don't store a size for the maximized state Fix #16666 When restoring from the maximized state while the maximized size was used when creating the window, the window manager restores to something sensible instead of using the last restored size we used. As the maximized size has no real use, don't store and use it. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 11 +---------- backends/platform/sdl/sdl-window.cpp | 6 +++++- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 52d916e0c70..6e282afe9a9 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -440,8 +440,6 @@ void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) { // Check if the ScummVM window is maximized and store the current // window dimensions. if (SDL_GetWindowFlags(_window->getSDLWindow()) & SDL_WINDOW_MAXIMIZED) { - ConfMan.setInt("window_maximized_width", currentWidth, Common::ConfigManager::kApplicationDomain); - ConfMan.setInt("window_maximized_height", currentHeight, Common::ConfigManager::kApplicationDomain); ConfMan.setBool("window_maximized", true, Common::ConfigManager::kApplicationDomain); } else { ConfMan.setInt("last_window_width", currentWidth, Common::ConfigManager::kApplicationDomain); @@ -478,15 +476,8 @@ bool OpenGLSdlGraphicsManager::loadVideoMode(uint requestedWidth, uint requested Common::Rect desktopRes = _window->getDesktopResolution(); #if SDL_VERSION_ATLEAST(2, 0, 0) - bool isMaximized = ConfMan.getBool("window_maximized", Common::ConfigManager::kApplicationDomain); if (!_wantsFullScreen) { - if (isMaximized && ConfMan.hasKey("window_maximized_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("window_maximized_height", Common::ConfigManager::kApplicationDomain)) { - // Set the window size to the values stored when the window was maximized - // for the last time. - requestedWidth = ConfMan.getInt("window_maximized_width", Common::ConfigManager::kApplicationDomain); - requestedHeight = ConfMan.getInt("window_maximized_height", Common::ConfigManager::kApplicationDomain); - - } else if (!isMaximized && ConfMan.hasKey("last_window_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_window_height", Common::ConfigManager::kApplicationDomain)) { + if (ConfMan.hasKey("last_window_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_window_height", Common::ConfigManager::kApplicationDomain)) { // Load previously stored window dimensions. requestedWidth = ConfMan.getInt("last_window_width", Common::ConfigManager::kApplicationDomain); requestedHeight = ConfMan.getInt("last_window_height", Common::ConfigManager::kApplicationDomain); diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp index 4f44c492f3c..931fa8686b0 100644 --- a/backends/platform/sdl/sdl-window.cpp +++ b/backends/platform/sdl/sdl-window.cpp @@ -539,7 +539,11 @@ bool SdlWindow::createOrUpdateWindow(int width, int height, uint32 flags) { SDL_SetWindowFullscreen(_window, fullscreenFlags); } else { SDL_SetWindowFullscreen(_window, fullscreenFlags); - SDL_SetWindowSize(_window, width, height); + if ((SDL_GetWindowFlags(_window) & SDL_WINDOW_MAXIMIZED) == 0) { + // Don't resize the window if we already are maximized + // This matches what SDL3 does + SDL_SetWindowSize(_window, width, height); + } if (flags & SDL_WINDOW_MAXIMIZED) { SDL_MaximizeWindow(_window); } else {