SDL
authorAlfred Reynolds <alfred@valvesoftware.com>
Wed, 29 Jul 2015 17:19:15 -0700
changeset 9820c0bcc39a3491
parent 9819 2361f732e8cb
child 9821 c1d91866a968
SDL
- add a new SDL_HINT_MAC_BACKGROUND_APP hint, when set or set to 1 don't force the app to be foreground
include/SDL_hints.h
src/video/cocoa/SDL_cocoaevents.m
     1.1 --- a/include/SDL_hints.h	Wed Jul 29 17:19:13 2015 -0700
     1.2 +++ b/include/SDL_hints.h	Wed Jul 29 17:19:15 2015 -0700
     1.3 @@ -526,6 +526,14 @@
     1.4  #define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES    "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
     1.5  
     1.6  /**
     1.7 +*  \brief  When set don't force the SDL app to become a foreground process
     1.8 +*
     1.9 +*  This hint only applies to Mac OS X.
    1.10 +*
    1.11 +*/
    1.12 +#define SDL_HINT_MAC_BACKGROUND_APP    "SDL_MAC_BACKGROUND_APP"
    1.13 +    
    1.14 +/**
    1.15   * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc.
    1.16   */
    1.17  #define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"
     2.1 --- a/src/video/cocoa/SDL_cocoaevents.m	Wed Jul 29 17:19:13 2015 -0700
     2.2 +++ b/src/video/cocoa/SDL_cocoaevents.m	Wed Jul 29 17:19:15 2015 -0700
     2.3 @@ -26,6 +26,7 @@
     2.4  #include "SDL_cocoavideo.h"
     2.5  #include "../../events/SDL_events_c.h"
     2.6  #include "SDL_assert.h"
     2.7 +#include "SDL_hints.h"
     2.8  
     2.9  /* This define was added in the 10.9 SDK. */
    2.10  #ifndef kIOPMAssertPreventUserIdleDisplaySleep
    2.11 @@ -318,19 +319,21 @@
    2.12          [SDLApplication sharedApplication];
    2.13          SDL_assert(NSApp != nil);
    2.14  
    2.15 +        const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
    2.16 +		if (!hint && *hint != '0') {
    2.17  #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
    2.18 -        if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
    2.19 +			if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
    2.20  #endif
    2.21 -            [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
    2.22 +				[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
    2.23  #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
    2.24 -        } else {
    2.25 -            ProcessSerialNumber psn = {0, kCurrentProcess};
    2.26 -            TransformProcessType(&psn, kProcessTransformToForegroundApplication);
    2.27 -        }
    2.28 +			} else {
    2.29 +				ProcessSerialNumber psn = {0, kCurrentProcess};
    2.30 +				TransformProcessType(&psn, kProcessTransformToForegroundApplication);
    2.31 +			}
    2.32  #endif
    2.33 -
    2.34 -        [NSApp activateIgnoringOtherApps:YES];
    2.35 -
    2.36 +            [NSApp activateIgnoringOtherApps:YES];
    2.37 +		}
    2.38 +		
    2.39          if ([NSApp mainMenu] == nil) {
    2.40              CreateApplicationMenus();
    2.41          }