Skip to content

Commit

Permalink
SDLMain.m: replace CPS* stuff with activateIgnoringOtherApps (bug #4114)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sezero committed Jun 22, 2018
1 parent 55e9787 commit ff4b715
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions src/main/macosx/SDLMain.m
Expand Up @@ -20,22 +20,6 @@ - (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;
Expand Down Expand Up @@ -201,18 +185,7 @@ static void CustomApplicationMain (int argc, char **argv)
SDLMain *sdlMain;

/* Ensure the application object is initialised */
[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 */
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES];

/* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]];
Expand Down Expand Up @@ -345,7 +318,6 @@ - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
@end



#ifdef main
# undef main
#endif
Expand Down

0 comments on commit ff4b715

Please sign in to comment.