summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--src/Fl_mac.cxx46
2 files changed, 46 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 44819a927..815b8946e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.8
+ - OS X resource fork now obsolete (STR #1453)
- Added chapter 10 about multithreading (STR #1532,
1533)
- OS X system menu bar itop level attribute support
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 );
+ }
+ }
}
}