Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

video: Ignore unfulfillable window size and position requests #11639

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Kontrabant
Copy link
Contributor

@Kontrabant Kontrabant commented Dec 12, 2024

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 to pending.x/y/w/h and deleting code related to the old behavior (no more WM_WINDOWPOSCHANGING needed on Win32 or special handling in windowWillResize 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).

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. 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.

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 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 while 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 there were still cases where async backends could end up overwriting pending state, and allows for the async backends to reliably handle cases such as leave fullscreen->set new size->center window, which was unreliable before, as the pending state would often be overwritten with the last real size/position values, causing a portion of the sequence to fail.

A small change to the automated test suite was also required, as one window state test was no longer applicable with the new rules.
@Kontrabant Kontrabant added this to the 3.2.0 milestone Dec 12, 2024
@Kontrabant Kontrabant changed the title video: Ignore unfulfillable size and position requests on windows video: Ignore unfulfillable window size and position requests Dec 12, 2024
@Kontrabant Kontrabant marked this pull request as draft December 13, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant