MACOS: OPENGLSDL: Maximizing a window doesn’t set SDL_WINDOW_MAXIMIZED flag.
|Reported by:||macca8||Owned by:|
|Priority:||normal||Component:||Port: Mac OS X|
Pressing the window title bar’s green button to maximize a window expands the window to fill the screen as expected, but registers in the config file as window_maximized=false.
The test in OpenGLSdlGraphicsManager::notifyResize() determines if a window is maximized by checking if its SDL_WINDOW_MAXIMIZED flag is set. Unfortunately, in macOS, this flag doesn’t always set as expected, resulting in the test incorrectly returning false. This appears to be a known SDL bug affecting macOS, included as part of this SDL bug report (I’m running macOS 10.11.6).
What this does is incorrectly assign the maximized values to the config file’s last_window_width/height settings, instead of creating the expected last_maximized_width/height entries.
If a user exits the maximized window other than by clicking the green button, the previous values are lost, and the maximized values become the default window size. When next entering windowed mode, these values may be adjusted further, reducing the window to the maximum size allowable for an unmaximized window.
The good news is that this bug doesn’t interfere with the ability to maximize a window, so the objective here is to modify the test in notifyResize() to enable macOS to correctly identify a maximized window.
I’m no expert here, and there’s probably a simple and obvious way of resolving this test (there usually is), however, I’d like to offer a couple of suggestions as food for thought, if I may.
The style of the window when maximized (at least in macOS 10.11.6) suggests that the SDL_WINDOW_FULLSCREEN_DESKTOP flag is set. A feature of this flag is that it resizes a maximized window to the equivalent of the desktop resolution (I’ve confirmed this by checking the config file’s entries while maximized), which is always larger than the unmaximized window.
This presents two possible tests:
- if this flag is only set when the window is maximized, add this flag to the existing test, such that if either flag is set (with priority given to SDL_WINDOW_MAXIMIZED), the test returns true.
- alternatively, test if the window’s size equals the desktop resolution, which would also return true.
Hopefully, if this can be resolved, it may address the odd macOS behaviour identified by criezy in PR 3400.
Applies to current daily builds and the 64-bit 2.5.0 release.