Skip to content
Permalink
Browse files

We still want to generally minimize on focus loss, but not when we're…

… in a fullscreen space on Mac OS X.
  • Loading branch information
slouken committed Nov 12, 2013
1 parent 75145ea commit 253b9ba815b558924867f45b0ad7eb00c73cc54f
Showing with 18 additions and 7 deletions.
  1. +6 −7 src/video/SDL_video.c
  2. +12 −0 src/video/cocoa/SDL_cocoawindow.m
@@ -115,6 +115,7 @@ static SDL_VideoDevice *_this = NULL;

#ifdef __MACOSX__
/* 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);
#endif

@@ -2152,19 +2153,17 @@ SDL_OnWindowFocusGained(SDL_Window * window)
static SDL_bool
ShouldMinimizeOnFocusLoss(SDL_Window * window)
{
SDL_bool default_minimize;
const char *hint;

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;
#ifdef __MACOSX__
if (Cocoa_IsWindowInFullscreenSpace(window)) {
return SDL_FALSE;
}
#endif

hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
if (hint) {
@@ -2175,7 +2174,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
}
}

return default_minimize;
return SDL_TRUE;
}

void
@@ -1382,6 +1382,18 @@ - (void)resetCursorRects
}
}

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
Cocoa_SetWindowFullscreenSpace(SDL_Window * window, SDL_bool state)
{

0 comments on commit 253b9ba

Please sign in to comment.