src/video/cocoa/SDL_cocoaevents.m
changeset 9820 c0bcc39a3491
parent 9619 b94b6d0bff0f
child 9822 371d82c6bf94
equal deleted inserted replaced
9819:2361f732e8cb 9820:c0bcc39a3491
    24 #include "SDL_timer.h"
    24 #include "SDL_timer.h"
    25 
    25 
    26 #include "SDL_cocoavideo.h"
    26 #include "SDL_cocoavideo.h"
    27 #include "../../events/SDL_events_c.h"
    27 #include "../../events/SDL_events_c.h"
    28 #include "SDL_assert.h"
    28 #include "SDL_assert.h"
       
    29 #include "SDL_hints.h"
    29 
    30 
    30 /* This define was added in the 10.9 SDK. */
    31 /* This define was added in the 10.9 SDK. */
    31 #ifndef kIOPMAssertPreventUserIdleDisplaySleep
    32 #ifndef kIOPMAssertPreventUserIdleDisplaySleep
    32 #define kIOPMAssertPreventUserIdleDisplaySleep kIOPMAssertionTypePreventUserIdleDisplaySleep
    33 #define kIOPMAssertPreventUserIdleDisplaySleep kIOPMAssertionTypePreventUserIdleDisplaySleep
    33 #endif
    34 #endif
   316 
   317 
   317     if (NSApp == nil) {
   318     if (NSApp == nil) {
   318         [SDLApplication sharedApplication];
   319         [SDLApplication sharedApplication];
   319         SDL_assert(NSApp != nil);
   320         SDL_assert(NSApp != nil);
   320 
   321 
       
   322         const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
       
   323 		if (!hint && *hint != '0') {
   321 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
   324 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
   322         if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
   325 			if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
   323 #endif
   326 #endif
   324             [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
   327 				[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
   325 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
   328 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
   326         } else {
   329 			} else {
   327             ProcessSerialNumber psn = {0, kCurrentProcess};
   330 				ProcessSerialNumber psn = {0, kCurrentProcess};
   328             TransformProcessType(&psn, kProcessTransformToForegroundApplication);
   331 				TransformProcessType(&psn, kProcessTransformToForegroundApplication);
   329         }
   332 			}
   330 #endif
   333 #endif
   331 
   334             [NSApp activateIgnoringOtherApps:YES];
   332         [NSApp activateIgnoringOtherApps:YES];
   335 		}
   333 
   336 		
   334         if ([NSApp mainMenu] == nil) {
   337         if ([NSApp mainMenu] == nil) {
   335             CreateApplicationMenus();
   338             CreateApplicationMenus();
   336         }
   339         }
   337         [NSApp finishLaunching];
   340         [NSApp finishLaunching];
   338         NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
   341         NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys: