summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2014-09-07 20:30:46 +0000
committerManolo Gouy <Manolo>2014-09-07 20:30:46 +0000
commit3e0bb410f85c68fe1d377865790deddef51da76c (patch)
tree48d2e840cf7cb94d1287c850b09997dda5ddb17c /src
parent2031e30069986f8e7fd9048ba062eb9b843964c1 (diff)
Handle deprecation with Mac OS 10.9 of SetFrontProcess(), GetCurrentProcess(), GetFrontProcess(), SameProcess().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10288 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 68b21dc43..77f7c1085 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -1413,29 +1413,36 @@ void fl_open_display() {
while (ign_event);
// 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 ) {
+ bool i_am_in_front;
+ ProcessSerialNumber cur_psn = { 0, kCurrentProcess };
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ if (fl_mac_os_version >= 100600) {
+ i_am_in_front = [[NSRunningApplication currentApplication] isActive];
+ }
+ else
+#endif
+ {
+ Boolean same_psn;
+ ProcessSerialNumber front_psn;
+ i_am_in_front = (!GetFrontProcess( &front_psn ) &&
+ !SameProcess( &front_psn, &cur_psn, &same_psn ) && same_psn );
+ }
+ if (!i_am_in_front) {
// only transform the application type for unbundled apps
NSBundle *bundle = [NSBundle mainBundle];
if (bundle) {
- NSString *exe = [[bundle executablePath] stringByStandardizingPath];
- NSString *bpath = [bundle bundlePath];
- NSString *exe_dir = [exe stringByDeletingLastPathComponent];
- if ([bpath isEqualToString:exe] || [bpath isEqualToString:exe_dir]) bundle = nil;
- }
-
- if ( !bundle )
- {
- OSErr err;
- err = TransformProcessType(&cur_psn, kProcessTransformToForegroundApplication); // needs Mac OS 10.3
- /* support of Mac OS 10.2 or earlier used this undocumented call instead
- err = CPSEnableForegroundOperation(&cur_psn, 0x03, 0x3C, 0x2C, 0x1103);
- */
- if (err == noErr) {
- SetFrontProcess( &cur_psn );
- }
+ NSString *exe = [[bundle executablePath] stringByStandardizingPath];
+ NSString *bpath = [bundle bundlePath];
+ NSString *exe_dir = [exe stringByDeletingLastPathComponent];
+ if ([bpath isEqualToString:exe] || [bpath isEqualToString:exe_dir]) bundle = nil;
+ }
+
+ if ( !bundle ) {
+ TransformProcessType(&cur_psn, kProcessTransformToForegroundApplication); // needs Mac OS 10.3
+ /* support of Mac OS 10.2 or earlier used this undocumented call instead
+ err = CPSEnableForegroundOperation(&cur_psn, 0x03, 0x3C, 0x2C, 0x1103);
+ */
+ [NSApp activateIgnoringOtherApps:YES];
}
}
if (![NSApp servicesMenu]) createAppleMenu();
@@ -2550,8 +2557,7 @@ void Fl_X::make(Fl_Window* w)
[myview registerForDraggedTypes:[NSArray arrayWithObjects:utf8_format, NSFilenamesPboardType, nil]];
if ( ! Fl_X::first->next ) {
// if this is the first window, we need to bring the application to the front
- ProcessSerialNumber psn = { 0, kCurrentProcess };
- SetFrontProcess( &psn );
+ [NSApp activateIgnoringOtherApps:YES];
}
if (w->size_range_set) w->size_range_();