From 1970df764d41ea0fe41f43dbbfa7f077c775e97a Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Wed, 13 Nov 2019 08:11:10 +0300 Subject: [PATCH] Update SDLMain.m fram SDL-1.2 tree. Reverts SDL-1.2 changeset 67f391c74aee after the breakage report See: https://bugzilla.libsdl.org/show_bug.cgi?id=4114#c5 --- Xcode/showimage/SDLMain.m | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Xcode/showimage/SDLMain.m b/Xcode/showimage/SDLMain.m index 6948979d..07d392ee 100644 --- a/Xcode/showimage/SDLMain.m +++ b/Xcode/showimage/SDLMain.m @@ -20,6 +20,22 @@ - (void)setAppleMenu:(NSMenu *)menu; /* 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; static BOOL gFinderLaunch; @@ -185,7 +201,18 @@ static void CustomApplicationMain (int argc, char **argv) SDLMain *sdlMain; /* Ensure the application object is initialised */ - [[NSApplication sharedApplication] activateIgnoringOtherApps: YES]; + [NSApplication 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)) + [NSApplication sharedApplication]; + } +#endif /* SDL_USE_CPS */ /* Set up the menubar */ [NSApp setMainMenu:[[NSMenu alloc] init]]; @@ -318,6 +345,7 @@ - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString @end + #ifdef main # undef main #endif