Skip to content

Commit

Permalink
We still want to generally minimize on focus loss, but not when we're…
Browse files Browse the repository at this point in the history
… in a fullscreen space on Mac OS X.
  • Loading branch information
slouken committed Nov 12, 2013
1 parent 75145ea commit 253b9ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/video/SDL_video.c
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand All @@ -2175,7 +2174,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
}
}

return default_minimize;
return SDL_TRUE;
}

void
Expand Down
12 changes: 12 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -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)
{
Expand Down

0 comments on commit 253b9ba

Please sign in to comment.