- Notifications
You must be signed in to change notification settings - Fork3.8k
Make sure set_mode always returns a cleared window#3317
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
I have a relevant piece of information from my experience with set_mode. Whether a window sticks around through set_mode or not is consistent and platform dependent. IIRC on MacOS a new window is created on a resize, for example, but not on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM 👍
Should at least be consistent now.
Starbuck5 commentedJul 24, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ok, I haven't really fleshed out this idea yet, but set_mode is also the window resizing API. It shouldn't lose the contents of the original window surface. I see this was kind of discussed. I think the fact that you are both testing on windows could be impacting this as well, because of different SDL_Window behavior across OSes. |
The idea behind this PR is to add consistency. It should be a documented API detail that As mentioned above, the behaviour from pygame 1.9.6 to pygame 2.1.2 on windows has been clearing the window. This is only breaking now as an affect of the SDL 2.0.22/2.0.20 update (on windows only) I also just tested on Ubuntu 22.04 (WSL) and the behaviour is the same as windows on pygame 2.1.2 (SDL 2.0.16), and I also had a SDL 2.0.22 wheel lying around from my manylinux PR (the one that is slow) and this too works the same the rest. I don't know the status of this on macs. |
I can't imagine many situations where pygame could successfully manage a window resizing eventwithout the user redrawing. Where do we put the pixels? Do we run a smoothscale on the display surface? Fill the new space with black pixels in the case of an enlargement? Cut off the surface when shrinking? I think always clearing to black is the easiest behaviour at pygame's level - because we can't know exactly what the application developer wants to happen when their window is resized. |
I just noticed this change is missing some docs, will add that rq |
It doesn't seem there is consensus yet on this one.
Does resizing the window leave the old surface just on windows? (or other platforms too?) To me, it's 99% clear that set_mode should definitely clear the surface the first time set_mode is called. |
Ok, since this is old behaviour; I agree that this patch should be merged. The new behaviour could be useful though, but perhaps that can be added with a flag. If there's no objections from@Starbuck5 I'd like to merge this for 2.1.3. |
fixes#3265
From the code, it seemed like retaining older window surface on subsequent
set_modecalls is intentional, but no pygame version from 1.9.6 to 2.1.2 actually does it (in my testing, on windows)This PR enforces the display clear on our end unconditionally when
set_modeis called