[Commits] SDL: SDL

libsdl.org revision control commits-owner at libsdl.org
Thu Jul 30 10:02:57 PDT 2015


details:   https://hg.libsdl.org/SDL/rev/c0bcc39a3491
changeset: 9820:c0bcc39a3491
user:      Alfred Reynolds <alfred at valvesoftware.com>
date:      Wed Jul 29 17:19:15 2015 -0700
description:
SDL
- add a new SDL_HINT_MAC_BACKGROUND_APP hint, when set or set to 1 don't force the app to be foreground

diffstat:

 include/SDL_hints.h               |   8 ++++++++
 src/video/cocoa/SDL_cocoaevents.m |  21 ++++++++++++---------
 2 files changed, 20 insertions(+), 9 deletions(-)

diffs (60 lines):

diff -r 2361f732e8cb -r c0bcc39a3491 include/SDL_hints.h
--- a/include/SDL_hints.h	Wed Jul 29 17:19:13 2015 -0700
+++ b/include/SDL_hints.h	Wed Jul 29 17:19:15 2015 -0700
@@ -526,6 +526,14 @@
 #define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES    "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
 
 /**
+*  \brief  When set don't force the SDL app to become a foreground process
+*
+*  This hint only applies to Mac OS X.
+*
+*/
+#define SDL_HINT_MAC_BACKGROUND_APP    "SDL_MAC_BACKGROUND_APP"
+    
+/**
  * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc.
  */
 #define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"
diff -r 2361f732e8cb -r c0bcc39a3491 src/video/cocoa/SDL_cocoaevents.m
--- a/src/video/cocoa/SDL_cocoaevents.m	Wed Jul 29 17:19:13 2015 -0700
+++ b/src/video/cocoa/SDL_cocoaevents.m	Wed Jul 29 17:19:15 2015 -0700
@@ -26,6 +26,7 @@
 #include "SDL_cocoavideo.h"
 #include "../../events/SDL_events_c.h"
 #include "SDL_assert.h"
+#include "SDL_hints.h"
 
 /* This define was added in the 10.9 SDK. */
 #ifndef kIOPMAssertPreventUserIdleDisplaySleep
@@ -318,19 +319,21 @@
         [SDLApplication sharedApplication];
         SDL_assert(NSApp != nil);
 
+        const char *hint = SDL_GetHint(SDL_HINT_MAC_BACKGROUND_APP);
+		if (!hint && *hint != '0') {
 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
-        if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
+			if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
 #endif
-            [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+				[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
-        } else {
-            ProcessSerialNumber psn = {0, kCurrentProcess};
-            TransformProcessType(&psn, kProcessTransformToForegroundApplication);
-        }
+			} else {
+				ProcessSerialNumber psn = {0, kCurrentProcess};
+				TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+			}
 #endif
-
-        [NSApp activateIgnoringOtherApps:YES];
-
+            [NSApp activateIgnoringOtherApps:YES];
+		}
+		
         if ([NSApp mainMenu] == nil) {
             CreateApplicationMenus();
         }


More information about the commits mailing list