We still want to generally minimize on focus loss, but not when we're in a fullscreen space on Mac OS X.

This commit is contained in:
Sam Lantinga 2013-11-12 02:02:12 -08:00
parent 75145ea023
commit 253b9ba815
2 changed files with 18 additions and 7 deletions

View File

@ -115,6 +115,7 @@ static SDL_VideoDevice *_this = NULL;
#ifdef __MACOSX__ #ifdef __MACOSX__
/* Support for Mac OS X fullscreen spaces */ /* Support for Mac OS X fullscreen spaces */
extern SDL_bool Cocoa_IsWindowInFullscreenSpace(SDL_Window * window);
extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state); extern SDL_bool Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state);
#endif #endif
@ -2152,19 +2153,17 @@ SDL_OnWindowFocusGained(SDL_Window * window)
static SDL_bool static SDL_bool
ShouldMinimizeOnFocusLoss(SDL_Window * window) ShouldMinimizeOnFocusLoss(SDL_Window * window)
{ {
SDL_bool default_minimize;
const char *hint; const char *hint;
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
return SDL_FALSE; return SDL_FALSE;
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { #ifdef __MACOSX__
/* We're not doing a mode switch, so it's okay to stay around */ if (Cocoa_IsWindowInFullscreenSpace(window)) {
default_minimize = SDL_FALSE; return SDL_FALSE;
} else {
default_minimize = SDL_TRUE;
} }
#endif
hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
if (hint) { if (hint) {
@ -2175,7 +2174,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
} }
} }
return default_minimize; return SDL_TRUE;
} }
void void

View File

@ -1382,6 +1382,18 @@ Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
} }
} }
SDL_bool
Cocoa_IsWindowInFullscreenSpace(SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if ([data->listener isInFullscreenSpace]) {
return SDL_TRUE;
} else {
return SDL_FALSE;
}
}
SDL_bool SDL_bool
Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state) Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
{ {