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

[OS X] SDL_SetWindowFullscreen fails to switch to windowed #1428

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

[OS X] SDL_SetWindowFullscreen fails to switch to windowed #1428

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

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: 2.0.3
Reported for operating system, platform: Mac OS X 10.8, x86

Comments on the original bug report:

On 2014-04-05 08:36:27 +0000, Jeffrey Carpenter wrote:

After setting the window to fullscreen using SDL_WINDOW_FULLSCREEN, the window becomes stuck in this mode, with no way of restoring the previous state. The issue can be confirmed using any of the test programs included in the SDL2 distribution:

Fire up 'testsprite2' for example and toggleFullscreen using 'CTRL +
Enter'. Window -> Fullscreen works fine but not Fullscreen ->
windowed.

However, when toggling using 'ALT + Enter' it works fine. This mode
uses 'SDL_WINDOW_FULLSCREEN_DESKTOP'.

'CTRL + Enter' uses 'SDL_WINDOW_FULLSCREEN' mode.

Original thread: https://forums.libsdl.org/viewtopic.php?t=10190&highlight=sdlsetwindowfullscreen+fails+switch+windowed

On 2014-05-16 22:29:03 +0000, Joe Swinbank wrote:

I'm wondering if this is related... Should window events be showing up in the event queue after a call to SDL_SetWindowFullscreen? I'm getting these on OS X 10.9, but not on my Win7 build running the same code.

[Start app windowed.]

PollEvents
Toggle to full-screen:
SDL_SetWindowFullscreen( ..., SDL_WINDOW_FULLSCREEN_DESKTOP )
.
.
PollEvents
Toggle to window:
SDL_SetWindowFullscreen( ..., 0 )
SDL_WINDOWEVENT_MAXIMIZED //Hmm?
.
.
PollEvents
Toggle to full-screen:
SDL_SetWindowFullscreen( ..., SDL_WINDOW_FULLSCREEN_DESKTOP )
SDL_WINDOWEVENT_RESTORED //?
.
.

Depending on how you react to events like these, Jeffrey, you could be inadvertently going back to full-screen right after you get your window.

On 2014-05-17 05:26:07 +0000, Eric Wasylishen wrote:

Created attachment 1649
proposed fix

The problem seems to be the spaces handling code in -setFullscreenSpace: (SDL_cocoawindow.m) is incorrectly reporting that the SDL_WINDOW_FULLSCREEN -> windowed transition has already happened.

i.e. I saw this case was getting hit when trying to leave SDL_WINDOW_FULLSCREEN:

"else if (state == isFullscreenSpace) {
return YES; /* already there. */
}"

With the attached patch, both Control+Enter (SDL_WINDOW_FULLSCREEN toggle) and Option+Enter (SDL_WINDOW_FULLSCREEN_DESKTOP toggle) work in an sdl test app (I tried testwm2). Tested on OS X 10.9.2.

On 2014-05-19 14:28:10 +0000, Jeffrey Carpenter wrote:

I have confirmed that Eric's fix does work for me as well, using his attached patch, on OS X v10.9.2. My tests were done using testsprite2 and testwm2.

Hope to see this included in the next revision release of SDL2 :-)

Joe,

Your question made me wonder a bit, too, although I can't say I know anything about the intentions of the code in regards to window events, nor have I looked into it...

The bug appeared to me to be related to SDL2 itself, and not in my code, since the test examples were not producing the (presumed) desired results. The patch that Eric has provided resolves the issue, in any regard.

On 2014-05-19 14:53:38 +0000, Joe Swinbank wrote:

I should have been more clear with my post. SDL_SetWindowFullscreen() does work for me, and without Eric's patch. The reason I stumbled upon this bug report is that I had a similar problem going from full-screen to window, but it was because of those odd window events showing up in my event queue after a call to SDL_SetWindowFullscreen(), and how my code was set up to respond to those.

Since full-screen -> window works for me, I'm not sure why it doesn't for you or for the test apps. But, the appearance of those window events on my OS X build and not on my Win7 build still makes me wonder what's going on. I have not yet tried Eric's patch.

On 2014-05-21 14:56:59 +0000, Jeffrey Carpenter wrote:

Ah, I see. This is very strange indeed, then. So much for the easy fix! :]

I'll try some detailed analysis of the events that I receive on my system here in the coming days and see what I get on my end.

My primary dev environment is OS X, but also have a Windows 7 box to test on as well.

I hope to get back with you on comparing notes!

On 2014-05-22 06:52:31 +0000, Eric Wasylishen wrote:

Hi,
Jeffrey, glad to hear the patch worked for you!

Joe, I just noticed that the code snippet you posted was using SDL_WINDOW_FULLSCREEN_DESKTOP. That could explain why fullscreen -> windowed was working for you without my patch. The specific case that Jeffrey and I hit, and my patch seems to resolve, only affects fullscreen -> windowed if the fullscreen mode was SDL_WINDOW_FULLSCREEN.

The spurious SDL_WINDOWEVENT_MAXIMIZED and SDL_WINDOWEVENT_RESTORED you're getting do sound like a problem - I don't handle those events so didn't notice it. Perhaps it'd be a good idea to post a separate bug about that just so it's more visible in the bugtracker?

Cheers
Eric

On 2014-05-23 19:25:47 +0000, Joe Swinbank wrote:

This is awkward. It just occurred to me that I'm using 2.0.1, not 2.0.3 as the bug report indicates. Guys, I apologize!

Just for the record, going from full-screen to window using SDL_WINDOW_FULLSCREEN in SDL 2.0.1 does also work correctly. So, it would be interesting to run a diff on SDL_cocoawindow.m through the versions to see where the problem was introduced.

I'll try to get linked up with 2.0.3 in the next couple days and see if those weird events are still showing up.

On 2014-05-23 19:34:03 +0000, Eric Wasylishen wrote:

Ok, that makes sense Joe. The thing my patch works around is a bug in the -setFullscreenSpace: method, that method was added (probably introducing this bug) in 2.0.2.

On 2014-05-24 07:18:47 +0000, Jeffrey Carpenter wrote:

Joe,

I appreciate letting me know, especially before I spent any time on hunting ghosts :-) Yeah, the bug appears to have been introduced in v2.0.2 or so, as I definitely did not have the problem in v2.0.1. If you are curious, check out commit SHA "56f7e38ff0bc", this is where I believe the bug was introduced.

P.S. I did run a quick test (using v2.0.3) and found no sign of the messages you described before. Who knows! I hope that Eric's patch takes care of you, too :-)

On 2014-05-29 16:15:43 +0000, philhassey wrote:

I haven't tested this patch, but I've had a related problem with 2.0.3. Possibly the same regression.

  1. call SDL_CreateWindow with SDL_WINDOW_FULLSCREEN (game appears in fullscreen)
  2. call it again without SDL_WINDOW_FULLSCREEN
  3. Screen appears black, game still in fullscreen.
  4. call SDL_CreateWindow with SDL_WINDOW_FULLSCREEN
  5. Screen appears again (in fullscreen)

I've got this bug in my game Galcon Legends. You can reproduce it here:

http://store.steampowered.com/app/201040/

Press CTRL-F to toggle between fullscreen and windowed mode. (So to reproduce, press it several times. Screen will go black instead of going into windowed mode.)

Bug was not present in earlier versions of the game that used SDL 2.0.1.

Thanks!
-Phil

On 2014-06-02 16:12:58 +0000, Sam Lantinga wrote:

This patch is in, thanks!
http://hg.libsdl.org/SDL/rev/2703c0c19f45

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

1 participant