| Summary: | [OS X] SDL_SetWindowFullscreen fails to switch to windowed | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jeffrey Carpenter <i8degrees> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | alt, ewasylishen, i8degrees, phil |
| Version: | 2.0.3 | ||
| Hardware: | x86 | ||
| OS: | Mac OS X 10.8 | ||
| Attachments: | proposed fix | ||
|
Description
Jeffrey Carpenter
2014-04-05 08:36:27 UTC
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. Created attachment 1649 [details]
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.
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. 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. 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! 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 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. 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. 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 :-) 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 This patch is in, thanks! http://hg.libsdl.org/SDL/rev/2703c0c19f45 |