diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2007-01-20 15:28:11 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2007-01-20 15:28:11 +0000 |
| commit | e9e0826d10ac38ab162c0407ee618d1edf93069d (patch) | |
| tree | 5067110648ed065583e84a56b2282b8e1cacdc07 /src | |
| parent | 84ad997529c888e5890ab35834b8bcfce9a009b1 (diff) | |
Made resource fork on OS X obsolete. We still do add it just in case, but should the data be lost during a copy process through a different file system, the app will still put itself in the foreground if using a GUI (STR #1453)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5627 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_mac.cxx | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index dc3782944..452d98774 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1264,8 +1264,16 @@ void fl_open_callback(void (*cb)(const char *)) { /** - * initialize the Mac toolboxes and set the default menubar + * initialize the Mac toolboxes, dock status, and set the default menubar */ + +#ifndef MAC_OS_X_VERSION_10_3 +extern "C" { +extern OSErr CPSEnableForegroundOperation(ProcessSerialNumber *psn, UInt32 _arg2, + UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); +} +#endif + void fl_open_display() { static char beenHereDoneThat = 0; if ( !beenHereDoneThat ) { @@ -1284,6 +1292,42 @@ void fl_open_display() { ClearMenuBar(); AppendResMenu( GetMenuHandle( 1 ), 'DRVR' ); DrawMenuBar(); + + // bring the application into foreground without a 'CARB' resource + Boolean same_psn; + ProcessSerialNumber cur_psn, front_psn; + if( !GetCurrentProcess( &cur_psn ) && !GetFrontProcess( &front_psn ) && + !SameProcess( &front_psn, &cur_psn, &same_psn ) && !same_psn ) + { + // only transform the application type for unbundled apps + CFBundleRef bundle = CFBundleGetMainBundle(); + if( bundle ) + { + FSRef execFs; + CFURLRef execUrl = CFBundleCopyExecutableURL( bundle ); + CFURLGetFSRef( execUrl, &execFs ); + + FSRef bundleFs; + GetProcessBundleLocation( &cur_psn, &bundleFs ); + + if( !FSCompareFSRefs( &execFs, &bundleFs ) ) + bundle = NULL; + + CFRelease(execUrl); + } + + if( !bundle ) + { +#ifdef MAC_OS_X_VERSION_10_3 + // newer supported API + if( !TransformProcessType( &cur_psn, kProcessTransformToForegroundApplication ) ) +#else + // undocumented API + if( !CPSEnableForegroundOperation( &cur_psn, 0x03, 0x3C, 0x2C, 0x1103 ) ) +#endif + SetFrontProcess( &cur_psn ); + } + } } } |
