[Scummvm-git-logs] scummvm master -> 1b68301540e09906479c8902d3f2228a3769a22f

lotharsm mail at serra.me
Tue Apr 27 05:25:45 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1b68301540 BACKENDS: OPENGLSDL: Properly handle maximized windows


Commit: 1b68301540e09906479c8902d3f2228a3769a22f
    https://github.com/scummvm/scummvm/commit/1b68301540e09906479c8902d3f2228a3769a22f
Author: Lothar Serra Mari (mail at serra.me)
Date: 2021-04-27T07:25:22+02:00

Commit Message:
BACKENDS: OPENGLSDL: Properly handle maximized windows

Changed paths:
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openglsdl/openglsdl-graphics.h


diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 314011fa17..65bf8e3bde 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -308,8 +308,20 @@ void OpenGLSdlGraphicsManager::notifyResize(const int width, const int height) {
 		currentWidth /= scale;
 		currentHeight /= scale;
 #endif
-		ConfMan.setInt("last_window_width", currentWidth, Common::ConfigManager::kApplicationDomain);
-		ConfMan.setInt("last_window_height", currentHeight, Common::ConfigManager::kApplicationDomain);
+		// Reset maximized flag
+		_windowIsMaximized == false;
+
+		// Check if the ScummVM window is maximized and store the current
+		// window dimensions.
+		if ((SDL_GetWindowFlags(_window->getSDLWindow()) & SDL_WINDOW_MAXIMIZED) == 128) {
+			_windowIsMaximized = true;
+			ConfMan.setInt("window_maximized_width", currentWidth, Common::ConfigManager::kApplicationDomain);
+			ConfMan.setInt("window_maximized_height", currentHeight, Common::ConfigManager::kApplicationDomain);
+		} else {
+			_windowIsMaximized = false;
+			ConfMan.setInt("last_window_width", currentWidth, Common::ConfigManager::kApplicationDomain);
+			ConfMan.setInt("last_window_height", currentHeight, Common::ConfigManager::kApplicationDomain);
+		}
 		ConfMan.flushToDisk();
 	}
 
@@ -343,11 +355,22 @@ bool OpenGLSdlGraphicsManager::loadVideoMode(uint requestedWidth, uint requested
 	_lastRequestedWidth  = requestedWidth;
 	_lastRequestedHeight = requestedHeight;
 
-	if (ConfMan.hasKey("last_window_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_window_height", Common::ConfigManager::kApplicationDomain)) {
+	if (_windowIsMaximized == true) {
+		// Set the window size to the values stored when the window was maximized
+		// for the last time. We also need to reset any scaling here.
+		requestedWidth  = ConfMan.getInt("window_maximized_width", Common::ConfigManager::kApplicationDomain);
+		requestedHeight = ConfMan.getInt("window_maximized_height", Common::ConfigManager::kApplicationDomain);
+		requestedWidth  = requestedWidth / requestedHeight;
+		requestedHeight = requestedWidth / requestedHeight;
+
+	} else if (ConfMan.hasKey("last_window_width", Common::ConfigManager::kApplicationDomain) && ConfMan.hasKey("last_window_height", Common::ConfigManager::kApplicationDomain)) {
+		// Restore previously stored window dimensions.
 		requestedWidth  = ConfMan.getInt("last_window_width", Common::ConfigManager::kApplicationDomain);
 		requestedHeight = ConfMan.getInt("last_window_height", Common::ConfigManager::kApplicationDomain);
+
 	} else {
 		// Set the basic window size based on the desktop resolution
+		// since we have no values stored, e.g. on first launch.
 		Common::Rect desktopRes = _window->getDesktopResolution();
 		requestedWidth  = desktopRes.width()  * 0.3f;
 		requestedHeight = desktopRes.height() * 0.4f;
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index 67059333c8..c663bf4a34 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -91,6 +91,7 @@ private:
 	bool _gotResize;
 
 	bool _wantsFullScreen;
+	bool _windowIsMaximized;
 	uint _ignoreResizeEvents;
 
 	struct VideoMode {




More information about the Scummvm-git-logs mailing list