Skip to content

Re-order display fullscreen handling and ensure toggle_fullscreen works for maximized window#3497

Merged
illume merged 4 commits intopygame:mainfrom
Temmie3754:display-flags-fixes
Feb 9, 2023
Merged

Re-order display fullscreen handling and ensure toggle_fullscreen works for maximized window#3497
illume merged 4 commits intopygame:mainfrom
Temmie3754:display-flags-fixes

Conversation

@Temmie3754
Copy link
Copy Markdown
Contributor

This PR resolves #2711 and #3107 by changing the order that changing the fullscreen flag is handled so that it sets the window to be not fullscreen before handling the borderless and resizeable flag as when in fullscreen SDL ignores these changes.
It also partly fixes #2380 as it succeeds at creating a fullscreen window and when exiting retains the resize flag of the window but it still results in a warning message as it has to recreate the window. The toggle function could likely still be improved in this regard but for now this PR fixes the main issues found with it.

Copy link
Copy Markdown
Contributor

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

Wow, I'm quite impressed!
This seemingly simple fix fixes 3 really complex-looking issues! 🥳 🎉
I could reproduce all three issues being fixed (the first 2 were spot on, the third toggle_fullscreen one was a bit problematic and I came across other minor and unrelated bugs, but the main issue in there is probably fixed)

We have other issues to be tracking toggle_fullscreen problems, and this PR does good progress already, thanks a ton! 🍰 🍕

(due to the nature of what this is fixing, I'd like if we could get more than 3 reviewers, and from my side I'm supporting this PR to quickly make it to the next dev release for wider testing)

@Temmie3754
Copy link
Copy Markdown
Contributor Author

I've updated it so that it now has the correct formatting and contains a comment for that specified section. I also wrote some further changes for the toggle_fullscreen so that it preserves these flags and the position as well. Also related issue #2698 is fixed by this PR. These changes will require further review to check that no issues are brought about by them.

Copy link
Copy Markdown
Contributor

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

I think the fullscreen_backup_x/fullscreen_backup_y stuff are redundant now. Those were added as part of #2460 to workaround a similar issue (and I suspect most of #2460 could now be reverted), because this fix of handling fullscreen first and then doing other display stuff also fixes the issue that PR was fixing

@Temmie3754
Copy link
Copy Markdown
Contributor Author

Unfortunately the backup positions are still required since those get modified when going into fullscreen as it changes the position to (0, 0) when entering fullscreen. Fullscreen was already handled before position anyway so it isn't affected by this change. This does however implement the same fix #2460 used for toggle_fullscreen now to enable position saving since that was left out when the PR was made.

src_c/display.c Outdated

flags = SDL_GetWindowFlags(win) & SDL_WINDOW_FULLSCREEN_DESKTOP;
flags = SDL_GetWindowFlags(win);
/* SDL_WINDOW_FULLSCREEN_DESKTOP includes SDL_WINDOW_FULLSCREEN */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that the line above is changed, the comment just below it seems a bit out of place. Should it be moved elsewhere?

win = SDL_CreateWindow(state->title, wx, wy, w, h, flags);
if (win == NULL) {
return RAISE(pgExc_SDLError, SDL_GetError());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The comment in this block of code says it's a hack for SDL 2.0.8 (which is a rather old version)... not sure whether it's relevant to this day? Would need someone running pygame on linux with x11 to check though

Copy link
Copy Markdown
Contributor

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

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

This fixes the two main linked issues for me, with the slight caveat that one of them also seems to want a resize able window without a frame which isn't a thing in the Windows platform where you resize and move windows by dragging the frame around.

@Temmie3754
Copy link
Copy Markdown
Contributor Author

Alright fixed that comment so it's now where the flag is actually mentioned, looks like everything has been resolved.

@illume illume added this to the 2.1.4 milestone Oct 23, 2022
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.

Thanks. Works really well.

@illume illume merged commit 6b70714 into pygame:main Feb 9, 2023
illume added a commit that referenced this pull request Apr 30, 2023
Re-order display fullscreen handling and ensure toggle_fullscreen works for maximized window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting Merge For PRs that have at least one approving review and can be merged on subsequent reviews display pygame.display

Projects

None yet

4 participants