mirror of https://github.com/encounter/SDL.git
SDL
- add a new SDL_HINT_MAC_BACKGROUND_APP hint, when set or set to 1 don't force the app to be foreground
This commit is contained in:
parent
5aaf81c84e
commit
628d8edb95
|
@ -525,6 +525,14 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
|
#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.
|
* \brief Android APK expansion main file version. Should be a string number like "1", "2" etc.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "SDL_cocoavideo.h"
|
#include "SDL_cocoavideo.h"
|
||||||
#include "../../events/SDL_events_c.h"
|
#include "../../events/SDL_events_c.h"
|
||||||
#include "SDL_assert.h"
|
#include "SDL_assert.h"
|
||||||
|
#include "SDL_hints.h"
|
||||||
|
|
||||||
/* This define was added in the 10.9 SDK. */
|
/* This define was added in the 10.9 SDK. */
|
||||||
#ifndef kIOPMAssertPreventUserIdleDisplaySleep
|
#ifndef kIOPMAssertPreventUserIdleDisplaySleep
|
||||||
|
@ -318,18 +319,20 @@ Cocoa_RegisterApp(void)
|
||||||
[SDLApplication sharedApplication];
|
[SDLApplication sharedApplication];
|
||||||
SDL_assert(NSApp != nil);
|
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 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
||||||
if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
|
if ([NSApp respondsToSelector:@selector(setActivationPolicy:)]) {
|
||||||
#endif
|
#endif
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
|
||||||
} else {
|
} else {
|
||||||
ProcessSerialNumber psn = {0, kCurrentProcess};
|
ProcessSerialNumber psn = {0, kCurrentProcess};
|
||||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
}
|
||||||
|
|
||||||
if ([NSApp mainMenu] == nil) {
|
if ([NSApp mainMenu] == nil) {
|
||||||
CreateApplicationMenus();
|
CreateApplicationMenus();
|
||||||
|
|
Loading…
Reference in New Issue