-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
display.toggle_fullscreen does not work when toggling a maximized window to fullscreen #2380
Comments
There was another bug about window maximing behaviour filed recently. I wrote the new toggle_fullscreen implementation, but unfortunately, I can't test on windows for the rest of the year. I'll try to see if your test case at least works as expected on X11 and wayland. toggle_fullscreen already tries to work around quirks in windows window management and upstream SDL2. Maybe the bug is in the handling of the windows special case (forgetting the flag), but again, I can't test this. Does this impact a game of yours? Creating a resizeable window the size of the screen is not a good idea (for rather annoying reasons) on other window managers as well... |
Yes, its the game engine I am writing for my own games that I want to make in the future. Most games will be like minesweeper: basic, rude forms, it does not have to be picture perfect, but it should allow the user to define the area on their screen they want to play on themselves (so they can open up other windows beside it as they please). Also: if they want, it should be able to go fullscreen/maximize/alt tab into and out off, anything they want to throw at it. |
I've done some investigating. The upside is that this function isn't completely broken: it works when the resolution of the window is the same as a display mode. |
I'm still having this issue, furthermore, at least on windows 11, it doesn't only happen if it is maximized, it seems to always happen as long as the window is resizeable. |
I fixed it in my framework as follow: def fixed_toggle_fullscreen():
if pygame.display.flags & pygame.FULLSCREEN == pygame.FULLSCREEN:
pygame.display.set_mode(pygame.display.windowed_size,
flags=pygame.display.flags ^ pygame.FULLSCREEN)
else:
pygame.display.windowed_size = pygame.display.get_surface().get_size()
pygame.display.set_mode(pygame.display.get_desktop_sizes()[0],
flags=pygame.display.flags | pygame.FULLSCREEN)
pump_windowresized()
pygame.display.toggle_fulscreen = fixed_toggle_fullscreen It works for me on windows (should work on linux too ?), including in an OPENGL context or with NOFRAME, whether the window is RESIZABLE, windowed maximized, at the original resolution or not. |
Environment:
pygame 2.0.0 (SDL 2.0.12, python 3.7.9)
Current behavior:
When toggling fullscreen from a windowed, maximized window, it tries to do it, fails, gives this warning:
Warning: re-creating window in toggle_fullscreen
then a windowed screen is displayed: that is not re-sizable
Expected behavior:
The same as non-maximized windows
Steps to reproduce:
Inspect the sample code: set isFullSreen to True if you want to start with a fullscreen (same behaviour)
Toggle fullscreen with F a couple of times: that works just fine.
then maximize the window, and press F to see the problem arise.
Test code
The text was updated successfully, but these errors were encountered: