We still want to generally minimize on focus loss, but not when we're in a fullscreen space on Mac OS X.
authorSam Lantinga <slouken@libsdl.org>
Tue, 12 Nov 2013 02:02:12 -0800
changeset 796972405c8b7dba
parent 7968 8c0afe77a1b2
child 7970 6dc794be47aa
We still want to generally minimize on focus loss, but not when we're in a fullscreen space on Mac OS X.
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/SDL_video.c	Tue Nov 12 01:52:54 2013 -0800
     1.2 +++ b/src/video/SDL_video.c	Tue Nov 12 02:02:12 2013 -0800
     1.3 @@ -115,6 +115,7 @@
     1.4  
     1.5  #ifdef __MACOSX__
     1.6  /* Support for Mac OS X fullscreen spaces */
     1.7 +extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
     1.8  extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
     1.9  #endif
    1.10  
    1.11 @@ -2152,19 +2153,17 @@
    1.12  static SDL_bool
    1.13  ShouldMinimizeOnFocusLoss(SDL_Window * window)
    1.14  {
    1.15 -    SDL_bool default_minimize;
    1.16      const char *hint;
    1.17  
    1.18      if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    1.19          return SDL_FALSE;
    1.20      }
    1.21  
    1.22 -    if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.23 -        /* We're not doing a mode switch, so it's okay to stay around */
    1.24 -        default_minimize = SDL_FALSE;
    1.25 -    } else {
    1.26 -        default_minimize = SDL_TRUE;
    1.27 +#ifdef __MACOSX__
    1.28 +    if (Cocoa_IsWindowInFullscreenSpace(window)) {
    1.29 +        return SDL_FALSE;
    1.30      }
    1.31 +#endif
    1.32  
    1.33      hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
    1.34      if (hint) {
    1.35 @@ -2175,7 +2174,7 @@
    1.36          }
    1.37      }
    1.38  
    1.39 -    return default_minimize;
    1.40 +    return SDL_TRUE;
    1.41  }
    1.42  
    1.43  void
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 12 01:52:54 2013 -0800
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Nov 12 02:02:12 2013 -0800
     2.3 @@ -1383,6 +1383,18 @@
     2.4  }
     2.5  
     2.6  SDL_bool
     2.7 +Cocoa_IsWindowInFullscreenSpace(SDL_Window * window)
     2.8 +{
     2.9 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    2.10 +
    2.11 +    if ([data->listener isInFullscreenSpace]) {
    2.12 +        return SDL_TRUE;
    2.13 +    } else {
    2.14 +        return SDL_FALSE;
    2.15 +    }
    2.16 +}
    2.17 +
    2.18 +SDL_bool
    2.19  Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
    2.20  {
    2.21      SDL_bool succeeded = SDL_FALSE;