From ec90a8778f8f7eab718503279b9a31c78b989c2b Mon Sep 17 00:00:00 2001 From: michi_cc Date: Sun, 4 Oct 2009 21:33:36 +0000 Subject: (svn r17712) -Codechange [FS#1411]: [OSX] Replace undocumented process manager API calls with a documented alternative. (pyth) --- src/video/cocoa/cocoa_v.mm | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/video/cocoa/cocoa_v.mm') diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index f8458e357..920a33830 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -44,17 +44,6 @@ * Read http://developer.apple.com/releasenotes/Cocoa/Objective-C++.html for more information. */ - -/* Portions of CPS.h */ -struct CPSProcessSerNum { - UInt32 lo; - UInt32 hi; -}; - -extern "C" OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); -extern "C" OSErr CPSEnableForegroundOperation(CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern "C" OSErr CPSSetFrontProcess(CPSProcessSerNum *psn); - /* Disables a warning. This is needed since the method exists but has been dropped from the header, supposedly as of 10.4. */ #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) @interface NSApplication(NSAppleMenu) @@ -171,17 +160,22 @@ static void setupWindowMenu() static void setupApplication() { - CPSProcessSerNum PSN; + ProcessSerialNumber psn = { 0, kCurrentProcess }; /* Ensure the application object is initialised */ [NSApplication sharedApplication]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 /* Tell the dock about us */ - if (!CPSGetCurrentProcess(&PSN) && - !CPSEnableForegroundOperation(&PSN, 0x03, 0x3C, 0x2C, 0x1103) && - !CPSSetFrontProcess(&PSN)) { - [NSApplication sharedApplication]; + if (MacOSVersionIsAtLeast(10, 3, 0)) { + OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication); + if (returnCode != 0) DEBUG(driver, 0, "Could not change to foreground application. Error %d", (int)returnCode); } +#endif + + /* Become the front process, important when start from the command line. */ + OSErr err = SetFrontProcess(&psn); + if (err != 0) DEBUG(driver, 0, "Could not bring the application to front. Error %d", (int)err); /* Set up the menubar */ [NSApp setMainMenu:[[NSMenu alloc] init]]; -- cgit v1.2.3-54-g00ecf