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
This commit is contained in:
Manolo Gouy 2014-09-07 20:30:46 +00:00
parent 2031e30069
commit 3e0bb410f8

View File

@ -1413,10 +1413,21 @@ void fl_open_display() {
while (ign_event);
// bring the application into foreground without a 'CARB' resource
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 cur_psn, front_psn;
if ( !GetCurrentProcess( &cur_psn ) && !GetFrontProcess( &front_psn ) &&
!SameProcess( &front_psn, &cur_psn, &same_psn ) && !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) {
@ -1426,16 +1437,12 @@ void fl_open_display() {
if ([bpath isEqualToString:exe] || [bpath isEqualToString:exe_dir]) bundle = nil;
}
if ( !bundle )
{
OSErr err;
err = TransformProcessType(&cur_psn, kProcessTransformToForegroundApplication); // needs Mac OS 10.3
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);
*/
if (err == noErr) {
SetFrontProcess( &cur_psn );
}
[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_();