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.
This commit is contained in:
Le Philousophe
2026-04-18 20:05:57 +02:00
parent fec10669b5
commit 994dc04a85
2 changed files with 6 additions and 11 deletions
@@ -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);
+5 -1
View File
@@ -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 {