Fixed bug 2479 - [OS X] SDL_SetWindowFullscreen fails to switch to windowed
authorSam Lantinga <slouken@libsdl.org>
Mon, 02 Jun 2014 09:01:10 -0700
changeset 87982703c0c19f45
parent 8797 cad43a408f22
child 8799 e2fd743d84ea
Fixed bug 2479 - [OS X] SDL_SetWindowFullscreen fails to switch to windowed

Eric Wasylishen

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.
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Jun 02 08:58:07 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Jun 02 09:01:10 2014 -0700
     1.3 @@ -268,6 +268,8 @@
     1.4          return NO;  /* Spaces are forcibly disabled. */
     1.5      } else if (state && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) {
     1.6          return NO;  /* we only allow you to make a Space on FULLSCREEN_DESKTOP windows. */
     1.7 +    } else if (!state && ((window->last_fullscreen_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) {
     1.8 +        return NO;  /* we only handle leaving the Space on windows that were previously FULLSCREEN_DESKTOP. */
     1.9      } else if (state == isFullscreenSpace) {
    1.10          return YES;  /* already there. */
    1.11      }