Skip to content

Fix leaving fullscreen creates window at (0,0)#2460

Merged
illume merged 3 commits intopygame:mainfrom
Starbuck5:main
Feb 14, 2021
Merged

Fix leaving fullscreen creates window at (0,0)#2460
illume merged 3 commits intopygame:mainfrom
Starbuck5:main

Conversation

@Starbuck5
Copy link
Copy Markdown
Contributor

@Starbuck5 Starbuck5 commented Jan 25, 2021

Targeted to fix #2360.

Over the past day I've been investigating issue #2360.
The window created inside set_mode() is supposed to get its position from the last window, if it exists.
The problem is that if the last window is a fullscreen window, SDL_GetWindowPosition() returns (0, 0).
Perhaps in SDL1 the window position values were saved in fullscreen windows, despite not being "real" - fullscreen windows don't have a position on the screen - they are the screen.

This solution works on Windows 10 and Mac.

Further things:

  • Is there a more elegant solution than adding special backup ints to be got/set in random circumstances?
  • Does this work on ubuntu? Other linux distros?

@robertpfeiffer
Copy link
Copy Markdown
Contributor

Does this work on ubuntu? Other linux distros?

Depending on the window manager, it already worked (but only when you compile from source and link against system SDL), or it can't be made to work (when you have a non-compliant window manager). I'll test it on Ubuntu's flavour of Gnome Shell under X and Wayland and report back...

@Starbuck5
Copy link
Copy Markdown
Contributor Author

Starbuck5 commented Jan 28, 2021

I think everything is fixed now.

I had a lot of trouble getting it to work until I moved the "Set_WindowPosition" under the "SDL_SetWindowFullscreen" - which makes sense. The whole cause of this trouble was fullscreen windows not holding locations, so windows coming out of fullscreen need to be repositioned after they leave fullscreen.

I've been testing with the example code in the issue. To test it starting in fullscreen change line 12: self.isFullScreen=True, to False.

Copy link
Copy Markdown
Member

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice one :)

@illume
Copy link
Copy Markdown
Member

illume commented Feb 14, 2021

Looks like the crash in Travis is unrelated, and seems to be crashing in lots of other PRs.

@illume
Copy link
Copy Markdown
Member

illume commented Feb 14, 2021

Does this work on ubuntu? Other linux distros?

Works for me on the gorilla Ubuntu with default settings, with pygame compiled from source.

@CodeGuru12
Copy link
Copy Markdown

Not sure what changed from Pygame 2.0.0 to 2.0.1, but there's still an issue with this on windows 10. My version is: pygame 2.0.1, using SDL 2.0.14, python 3.9.4 with windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display pygame.display

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pygame 2.0.0 puts window at (0,0) when toggling back from full-screen, hiding the top bar. (worked fine in 1.9.6)

4 participants