Tell the dock about command-line launched applications
authorSam Lantinga <slouken@libsdl.org>
Sat, 31 Aug 2002 04:01:19 +0000
changeset 476 a7129c0083f4
parent 475 429fe382fe4f
child 477 22581630aab7
Tell the dock about command-line launched applications
src/main/macosx/SDLMain.m
--- a/src/main/macosx/SDLMain.m	Sat Aug 31 01:31:44 2002 +0000
+++ b/src/main/macosx/SDLMain.m	Sat Aug 31 04:01:19 2002 +0000
@@ -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 @@
     /* 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();