From 9e3cd3c66ef8c95fc69280783b092c16995c4257 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 31 Aug 2002 04:01:19 +0000 Subject: [PATCH] Tell the dock about command-line launched applications --- src/main/macosx/SDLMain.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/macosx/SDLMain.m b/src/main/macosx/SDLMain.m index 0c757d1ac..9a5d04ab0 100644 --- a/src/main/macosx/SDLMain.m +++ b/src/main/macosx/SDLMain.m @@ -13,6 +13,21 @@ /* Use this flag to determine whether we use SDLMain.nib or not */ #define SDL_USE_NIB_FILE 0 +/* Use this flag to determine whether we use CPS (docking) or not */ +#define SDL_USE_CPS 1 +#ifdef SDL_USE_CPS +/* Portions of CPS.h */ +typedef struct CPSProcessSerNum +{ + UInt32 lo; + UInt32 hi; +} CPSProcessSerNum; + +extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); +extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); +extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); + +#endif /* SDL_USE_CPS */ static int gArgc; static char **gArgv; @@ -162,6 +177,17 @@ void CustomApplicationMain (argc, argv) /* Ensure the application object is initialised */ [SDLApplication sharedApplication]; +#ifdef SDL_USE_CPS + { + CPSProcessSerNum PSN; + /* Tell the dock about us */ + if (!CPSGetCurrentProcess(&PSN)) + if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) + if (!CPSSetFrontProcess(&PSN)) + [SDLApplication sharedApplication]; + } +#endif /* SDL_USE_CPS */ + /* Set up the menubar */ [NSApp setMainMenu:[[NSMenu alloc] init]]; setupAppleMenu();