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

Mac OS X: SDL_WINDOW_FULLSCREEN is unset after using window controls to fullscreen-ify an SDL_WINDOW_RESIZABLE window #2561

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 3 comments
Assignees
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: macOS 10.12, All

Comments on the original bug report:

On 2017-08-21 22:04:46 +0000, David Ludwig wrote:

Created attachment 2873
code for sample application

Clicking on OSX's green, 'make fullscreen' button (in modern versions of Mac OS X) on an SDL_Window, one which was created with SDL_WINDOW_RESIZABLE, will make the window appear to go fullscreen, however, subsequent calls to SDL_GetWindowFlags() on the window do not return values with the SDL_WINDOW_FULLSCREEN bit being set.

A sample application is attached.

Steps to reproduce:

  1. on a modern, OSX system (MacOS Sierra / 10.12 was used to reproduce this, however a couple of versions back should also work fine), create a Mac app that creates a windowed/non-fullscreen window, with SDL_WINDOW_RESIZABLE applied in the window's creation flags.

  2. wait for the app to finish launching.

  3. if using the attached sample app, observe that a yellow-filled window appears. The yellow is used to indicate that the current app's window flags do not have SDL_WINDOW_FULLSCREEN set. ('green' will be used to indicate SDL_WINDOW_FULLSCREEN being set. This'll be important, later.)

  4. on the right side of the SDL window's title bar, find the green/maximize button (as provided by OSX). Click on it.

  5. observe that OSX will make the window go fullscreen, and will also allocate a new desktop for it.

  6. wait for the window to finish going fullscreen. Waiting a few seconds, here, should be sufficient.

Expected Results:

  • if using the attached sample app, the now-fullscreen window's content will have changed to green. The green indicates that SDL_WINDOW_FULLSCREEN has been set (whereas 'yellow' indicates no such setting).
  • if not using the attached sample app, calling SDL_GetWindowFlags() on the SDL_Window, should return a value with the SDL_WINDOW_FULLSCREEN bit being set.

Observed Results:

  • if using the attached sample app, the now-fullscreen window's content will still be yellow. The yellow indicates that SDL_WINDOW_FULLSCREEN has NOT been set ('green' is used if and when that bit is set.)
  • if not using the attached sample app, calling SDL_GetWindowFlags() on the SDL_Window, will return a value whereby the SDL_WINDOW_FULLSCREEN bit is NOT set.

On 2017-08-22 02:41:20 +0000, Alex Szpakowski wrote:

This is intentional behaviour, I believe. Putting an app into its own Space intentionally doesn't do exactly the same as what SDL_WINDOW_FULLSCREEN_DESKTOP does (for example in fs-desktop the dock and menubar are always hidden).

On 2017-08-22 12:45:00 +0000, David Ludwig wrote:

Regarding whether SDL_WINDOW_FULLSCREEN should be set/unset, perhaps. This seemed non-obvious to me, and having a displayable dock and/or menu bar, alongside SDL_WINDOW_FULLSCREEN, does not seem mutually exclusive to me. Perhaps with SDL_WINDOW_FULLSCREEN_DESKTOP, it should be, but I am uncertain of this.

On a similar note, after writing this up, I did notice a similar bug, whereby SDL_WINDOW_MAXIMIZED will often not get set, either. This did not happen if and when I debug-stepped through the code, but did happen if I let the program run, without any breakpoints. I presume the difference was a timing issue, given that it occurred in the same, Debug build, and always with a debugger attached. If anyone likes, I could attach a modified version of the test program, to demonstrate this, and/or write up an additional bug report on it.

On 2017-08-22 15:37:53 +0000, Alex Szpakowski wrote:

(In reply to David Ludwig from comment # 2)

Regarding whether SDL_WINDOW_FULLSCREEN should be set/unset, perhaps. This
seemed non-obvious to me, and having a displayable dock and/or menu bar,
alongside SDL_WINDOW_FULLSCREEN, does not seem mutually exclusive to me.
Perhaps with SDL_WINDOW_FULLSCREEN_DESKTOP, it should be, but I am uncertain
of this.

See also: https://hg.libsdl.org/SDL/rev/a2910aa6c056 (the original commit).

Fullscreen state is only set through programmatic means and it would break a lot of existing code if that changed. Putting a window into its own Space in macOS is not true fullscreen (or even fullscreen-desktop) in terms of what SDL defines it as, either, so there are multiple axes where the current approach makes the most sense, I think.

On 2017-08-22 17:02:05 +0000, David Ludwig wrote:

As a point of reference, OSX's APIs do, in some ways, seem to treat an app that's getting its own space as if it were "fullscreen", at least in terms of API-naming conventions. When the green, zoom control is clicked, OS X will end up invoking the windows' NSWindow*FullScreenNotification observers (NSWindowDidEnterFullScreenNotification, etc.). OS X also appears to be toggling the NSWindow styleMask's NSWindowStyleMaskFullScreen flag: it sets it after going to fullscreen, and unsets it before going back to windowed mode (solely via use of OSX window controls).

Whether or not this should be 'fixed', I cannot say, however this does seem like a discrepency in what SDL2 reports.

For what it is worth, I struggled with this when working on the UWP backend, whereby the OS could, under certain circumstances, force a windowed-mode application into fullscreen. SDL did not, at the time, appear very amenable to having its SDL_WINDOW_FULLSCREEN* flags be set, but it ultimately was possible, but arguably, might be buggy/unexpected.

I do, also, see some code in SDL's X11 backend that appears to detect changes to fullscreen state. I'm not terribly familiar with that code, and am unsure, offhand, if it can modify an SDL_Window's flags, and if so, with what steps.

On 2017-08-22 17:07:52 +0000, David Ludwig wrote:

Out of curiosity, what bugs could, or would come up, if SDL were to report fullscreen mode changes?

This does seem like a relatively new-ish, or just a rejuvenated thing, in window management, one that seems to becoming a bit more widespread these days.

On 2017-08-22 17:29:34 +0000, David Ludwig wrote:

An additional note: in my testing, when using the zoom control, the Mac window does appear to be doing more than just maximizing: it resizes the window to cover the menu bar and the dock. Both the menu bar and dock can appear, if and when the cursor is moved to either the top or bottom of the screen, however they are covered by default.

I wonder if there is warrant for new API(s) to SDL, here, to help with OS/WM-driven fullscreen/windowed mode changes. I'm a bit hazy on what those ought to be though.

On 2019-04-28 20:00:33 +0000, Edward Rudd wrote:

What about adding an SDL hint to control behavior? As I see there are 3 behaviors that a developer may want.

  1. The current behavior where it goes into a "fully maximized window but not considered fullscreen desktop" (e.g. can access menu bar and dock)
  2. where it goes into a proper fullscreen_desktop (with all the same behaviors as FS Desktop.
  3. disable/don't allow the fullscreen button in the window bar

I was working on updating a game for a developer and they noticed this (# 1) behavior an didn't like it. they wanted the "green button" to behave like # 2. What I ended up doing is adding a "hack" to FORCE the collectionBehavior when the window is fullscreen to not add the 'full screen' so now it's a regular maximize (as the developer wanted the window resizable)

If I could get thoughts on this / confirmation that it's a good direction to go I can work up a changeset.

@ericoporto
Copy link
Contributor

Hey, was there any follow up on this one?

@slouken slouken removed the bug label May 11, 2022
@slouken slouken closed this as completed Nov 5, 2023
@slouken slouken reopened this Nov 5, 2023
@slouken slouken added this to the 2.30.0 milestone Nov 5, 2023
@slouken
Copy link
Collaborator

slouken commented Nov 5, 2023

@icculus, can you check this for the next release?

@icculus
Copy link
Collaborator

icculus commented Nov 28, 2023

So this still doesn't set the FULLSCREEN or FULLSCREEN_DESKTOP bits when you click the green button, but I'm super hesitant to change this, at least in SDL2 but maybe also in SDL3.

Trying to coerce this to work in X11 was a nightmare that we eventually gave up on, and Cocoa's idea of "fullscreen" with that green button is close but not identical to SDL's behavior.

I say we close this as WONTFIX.

@icculus icculus closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
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

No branches or pull requests

4 participants