video: Ignore unfulfillable window size and position requests #11639
+271
−254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is not uncommon for clients to send redundant window size and position requests, either as a holdover from when it was required in SDL 1, or as part of a universal function that updates all window state, called whenever anything changes (e.g. calling
SDL_SetWindowSize()
with the current size of the window whenever anything changes, even if it is fullscreen). In SDL2 it was usually accepted that the new size/position would be dropped if the window wasn't in a moveable/resizable state, as opposed to the last requested size/position being deferred until it could be applied as SDL 3 does, so these clients are seeing unexpected behavior on SDL 3 when they leave fullscreen or maximized, and the window isn't the same size or in the same position that it was before entering the fixed-size state.This changes the behavior of the size and position functions, such that the requests are dropped if called for a window in a fixed size/position state (e.g. a fullscreen window can't be resized, so a resize request on a fullscreen window will just be ignored vs being cached for when it leaves fullscreen). This provides behavior more in-line with what real-world apps/games expect. Cases where size/position requests are made immediately while the window is asynchronously coming out of a fixed size/position state are still supported and work as expected.
A few other cleanups are also included, primarily storing the pending window state separately from the current window state, as while working on this I was running into additional cases where async backends could end up overwriting pending state, and the workarounds were becoming too elaborate. This is cleaner, and allows for better handling of cases such as fullscreen display selection with the pending size and coordinates.
The changes also fix an edge case bug on KDE, where the window would become the wrong size by a couple of pixels if it was resized right when restoring from maximized mode.
A small change to the automated test suite was also required, as one window state test was no longer applicable with the new rules.
This does touch several files, however, most changes are just
floating.x/y/w/h
topending.x/y/w/h
and deleting code related to the old behavior (no moreWM_WINDOWPOSCHANGING
needed on Win32 or special handling inwindowWillResize
on Mac). No regressions were noted in the automated tests or with manual testing.Fixes cases such as #11561, which others will undoubtedly encounter as more apps/games are ported to SDL3. In addition to that issue, I've found other real world cases where this differing behavior causes problems, particularly when running things via sdl2-compat (SuperTux, for example, returns to the wrong window size when leaving fullscreen).