From: James Turner Date: Sat, 21 Dec 2013 15:29:11 +0000 (+0000) Subject: Cocoa: fix warning about deprecated function. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4c51ad0d8728179528af0b3acd828ef1ec668e67;p=flightgear.git Cocoa: fix warning about deprecated function. SetFrontProcess is deprecated, use NSApplication instead now we have the CocoaHelpers file. --- diff --git a/src/GUI/CocoaHelpers.h b/src/GUI/CocoaHelpers.h index 9b4802a28..9c999778e 100644 --- a/src/GUI/CocoaHelpers.h +++ b/src/GUI/CocoaHelpers.h @@ -34,4 +34,11 @@ void cocoaOpenUrl(const std::string& url); */ SGPath platformDefaultDataPath(); +/** + * When we run non-bundled, we need to transform to a GUI (foreground) app + * osgViewer does this for us normally, but we need to do it ourselves + * to show a message box before OSG is initialized. + */ +void transformToForegroundApp(); + #endif // of FG_GUI_COCOA_HELPERS_H \ No newline at end of file diff --git a/src/GUI/CocoaHelpers.mm b/src/GUI/CocoaHelpers.mm index cc564a2b0..70454f1f4 100644 --- a/src/GUI/CocoaHelpers.mm +++ b/src/GUI/CocoaHelpers.mm @@ -151,3 +151,12 @@ string_list FGLocale::getUserLanguage() return result; } + +void transformToForegroundApp() +{ + ProcessSerialNumber sn = { 0, kCurrentProcess }; + TransformProcessType(&sn,kProcessTransformToForegroundApplication); + + + [[NSApplication sharedApplication] activateIgnoringOtherApps: YES]; +} diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index 2b5cb2b26..be6c595b5 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -64,7 +64,7 @@ using std::endl; #include "fg_os.hxx" #if defined(SG_MAC) -#include + #include // for transformToForegroundApp #endif std::string homedir; @@ -164,9 +164,7 @@ int main ( int argc, char **argv ) #if defined(SG_MAC) // required so native messages boxes work prior to osgViewer init // (only needed when not running as a bundled app) - ProcessSerialNumber sn = { 0, kCurrentProcess }; - TransformProcessType(&sn,kProcessTransformToForegroundApplication); - SetFrontProcess(&sn); + transformToForegroundApp(); #endif #ifdef PTW32_STATIC_LIB