Don't minimize by default when in fullscreen desktop mode.
authorSam Lantinga <slouken@libsdl.org>
Mon, 11 Nov 2013 03:02:42 -0800
changeset 7953255ca6c77e58
parent 7952 5ac1a895b313
child 7954 712d8544f8a1
Don't minimize by default when in fullscreen desktop mode.
This fixes behavior with the new Mac OS X fullscreen space code, as well as improve behavior on Linux desktops.
The default for normal fullscreen mode is still to minimize because we're likely doing a mode switch and don't want to stick around as a borderless window in the background.
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_video.c	Mon Nov 11 02:53:00 2013 -0800
     1.2 +++ b/src/video/SDL_video.c	Mon Nov 11 03:02:42 2013 -0800
     1.3 @@ -2134,8 +2134,22 @@
     1.4      SDL_UpdateWindowGrab(window);
     1.5  }
     1.6  
     1.7 -static SDL_bool ShouldMinimizeOnFocusLoss()
     1.8 +static SDL_bool
     1.9 +ShouldMinimizeOnFocusLoss(SDL_Window * window)
    1.10  {
    1.11 +    SDL_bool default_minimize;
    1.12 +
    1.13 +    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    1.14 +        return SDL_FALSE;
    1.15 +    }
    1.16 +
    1.17 +    if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
    1.18 +        /* We're not doing a mode switch, so it's okay to stay around */
    1.19 +        default_minimize = SDL_FALSE;
    1.20 +    } else {
    1.21 +        default_minimize = SDL_TRUE;
    1.22 +    }
    1.23 +
    1.24      const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
    1.25      if (hint) {
    1.26          if (*hint == '0') {
    1.27 @@ -2144,7 +2158,8 @@
    1.28              return SDL_TRUE;
    1.29          }
    1.30      }
    1.31 -    return SDL_TRUE;
    1.32 +
    1.33 +    return default_minimize;
    1.34  }
    1.35  
    1.36  void
    1.37 @@ -2156,8 +2171,7 @@
    1.38  
    1.39      SDL_UpdateWindowGrab(window);
    1.40  
    1.41 -    /* If we're fullscreen and lose focus, minimize unless the hint tells us otherwise */
    1.42 -    if ((window->flags & SDL_WINDOW_FULLSCREEN) && ShouldMinimizeOnFocusLoss()) {
    1.43 +    if (ShouldMinimizeOnFocusLoss(window)) {
    1.44          SDL_MinimizeWindow(window);
    1.45      }
    1.46  }