SDLMain.m: replace CPS* stuff with activateIgnoringOtherApps (bug #4114) SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Fri, 22 Jun 2018 21:03:40 +0300
branchSDL-1.2
changeset 1202667f391c74aee
parent 11979 d684a767e240
child 12047 160a0e63e641
SDLMain.m: replace CPS* stuff with activateIgnoringOtherApps (bug #4114)

CPS stuff are deprecated and emit warnings at runtime, e.g.:

warning: CPSGetCurrentProcess(): This call is deprecated and should not be called anymore
warning: CPSSetForegroundOperationState() (as above)
warning: capture_display; Captured mirror master 0x350000c1 (unit 1) on behalf of slave 0x042716c0 (unit 0)

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2006-April/055749.html
suggests doing something like:

ProcessSerialNumber psn = { 0, kCurrentProcess};
TransformProcessType (&psn, kProcessTransformToForegroundApplication);
SetFrontProcess (&psn);

And SetFrontProcess() is deprecated in 10.9. Processes.h suggests
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES]
to make one's own application frontmost.
src/main/macosx/SDLMain.m
     1.1 --- a/src/main/macosx/SDLMain.m	Thu May 10 08:47:00 2018 +0300
     1.2 +++ b/src/main/macosx/SDLMain.m	Fri Jun 22 21:03:40 2018 +0300
     1.3 @@ -20,22 +20,6 @@
     1.4  /* Use this flag to determine whether we use SDLMain.nib or not */
     1.5  #define		SDL_USE_NIB_FILE	0
     1.6  
     1.7 -/* Use this flag to determine whether we use CPS (docking) or not */
     1.8 -#define		SDL_USE_CPS		1
     1.9 -#ifdef SDL_USE_CPS
    1.10 -/* Portions of CPS.h */
    1.11 -typedef struct CPSProcessSerNum
    1.12 -{
    1.13 -	UInt32		lo;
    1.14 -	UInt32		hi;
    1.15 -} CPSProcessSerNum;
    1.16 -
    1.17 -extern OSErr	CPSGetCurrentProcess( CPSProcessSerNum *psn);
    1.18 -extern OSErr 	CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
    1.19 -extern OSErr	CPSSetFrontProcess( CPSProcessSerNum *psn);
    1.20 -
    1.21 -#endif /* SDL_USE_CPS */
    1.22 -
    1.23  static int    gArgc;
    1.24  static char  **gArgv;
    1.25  static BOOL   gFinderLaunch;
    1.26 @@ -201,18 +185,7 @@
    1.27      SDLMain				*sdlMain;
    1.28  
    1.29      /* Ensure the application object is initialised */
    1.30 -    [NSApplication sharedApplication];
    1.31 -    
    1.32 -#ifdef SDL_USE_CPS
    1.33 -    {
    1.34 -        CPSProcessSerNum PSN;
    1.35 -        /* Tell the dock about us */
    1.36 -        if (!CPSGetCurrentProcess(&PSN))
    1.37 -            if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
    1.38 -                if (!CPSSetFrontProcess(&PSN))
    1.39 -                    [NSApplication sharedApplication];
    1.40 -    }
    1.41 -#endif /* SDL_USE_CPS */
    1.42 +    [[NSApplication sharedApplication] activateIgnoringOtherApps: YES];
    1.43  
    1.44      /* Set up the menubar */
    1.45      [NSApp setMainMenu:[[NSMenu alloc] init]];
    1.46 @@ -345,7 +318,6 @@
    1.47  @end
    1.48  
    1.49  
    1.50 -
    1.51  #ifdef main
    1.52  #  undef main
    1.53  #endif