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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 46796e8..44f3daa 100755
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -2134,8 +2134,22 @@ SDL_OnWindowFocusGained(SDL_Window * window)
SDL_UpdateWindowGrab(window);
}
-static SDL_bool ShouldMinimizeOnFocusLoss()
+static SDL_bool
+ShouldMinimizeOnFocusLoss(SDL_Window * window)
{
+ SDL_bool default_minimize;
+
+ if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+ return SDL_FALSE;
+ }
+
+ if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
+ /* We're not doing a mode switch, so it's okay to stay around */
+ default_minimize = SDL_FALSE;
+ } else {
+ default_minimize = SDL_TRUE;
+ }
+
const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
if (hint) {
if (*hint == '0') {
@@ -2144,7 +2158,8 @@ static SDL_bool ShouldMinimizeOnFocusLoss()
return SDL_TRUE;
}
}
- return SDL_TRUE;
+
+ return default_minimize;
}
void
@@ -2156,8 +2171,7 @@ SDL_OnWindowFocusLost(SDL_Window * window)
SDL_UpdateWindowGrab(window);
- /* If we're fullscreen and lose focus, minimize unless the hint tells us otherwise */
- if ((window->flags & SDL_WINDOW_FULLSCREEN) && ShouldMinimizeOnFocusLoss()) {
+ if (ShouldMinimizeOnFocusLoss(window)) {
SDL_MinimizeWindow(window);
}
}