summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index a9bb0cf00..2b359abbb 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -1599,16 +1599,24 @@ void Fl_Darwin_System_Driver::open_callback(void (*cb)(const char *)) {
}
*/
-static void foreground_and_activate_if_needed() {
- if ([NSApp isActive]) return;
- 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 ) { // only transform the application type for unbundled apps
+static BOOL is_bundled() {
+ static int value = 2;
+ if (value == 2) {
+ value = 1;
+ 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]) value = 0;
+ }
+ }
+ return value == 1;
+}
+
+
+static void foreground_and_activate() {
+ if ( !is_bundled() ) { // only transform the application type for unbundled apps
ProcessSerialNumber cur_psn = { 0, kCurrentProcess };
TransformProcessType(&cur_psn, kProcessTransformToForegroundApplication); // needs Mac OS 10.3
/* support of Mac OS 10.2 or earlier used this undocumented call instead
@@ -1618,7 +1626,7 @@ static void foreground_and_activate_if_needed() {
[NSApp activateIgnoringOtherApps:YES];
}
-// simpler way to activate application tested OK on MacOS 10.3 10.6 10.9 and 10.13
+// simpler way to activate application tested OK on MacOS 10.3 10.6 10.9 10.13 and 10.14 public beta
void Fl_Cocoa_Screen_Driver::open_display_platform() {
static char beenHereDoneThat = 0;
@@ -1632,8 +1640,8 @@ void Fl_Cocoa_Screen_Driver::open_display_platform() {
FLAppDelegate *delegate = (Fl_Darwin_System_Driver::calc_mac_os_version() < 100500 ? [FLAppDelegateBefore10_5 alloc] : [FLAppDelegate alloc]);
[(NSApplication*)NSApp setDelegate:[delegate init]];
if (need_new_nsapp) {
- if (fl_mac_os_version >= 101300 ) {
- foreground_and_activate_if_needed();
+ if (fl_mac_os_version >= 101300 && is_bundled() ) {
+ [NSApp activateIgnoringOtherApps:YES];
in_nsapp_run = true;
[NSApp run];
in_nsapp_run = false;
@@ -1649,7 +1657,7 @@ void Fl_Cocoa_Screen_Driver::open_display_platform() {
dequeue:YES];
while (ign_event);
- foreground_and_activate_if_needed();
+ if (![NSApp isActive]) foreground_and_activate();
if (![NSApp servicesMenu]) createAppleMenu();
main_screen_height = CGDisplayBounds(CGMainDisplayID()).size.height;
[[NSNotificationCenter defaultCenter] addObserver:[FLWindowDelegate singleInstance]