summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-09-16 10:17:23 +0000
committerManolo Gouy <Manolo>2018-09-16 10:17:23 +0000
commit3131757e9c6f1bcb461c04eb691de3f75a92f974 (patch)
treec45445d3d6eb73b46b6f961c1aba9d61520f738d /src
parentf2356788510766871d32a78783de866a38950d57 (diff)
MacOS: fix regression in OS 10.13 where an unbundled app had its system menu bar unresponsive.
The regression was detected by "FLTK 1.4 on macOS: Trouble compiling my Application with Makefile" in fltk.general. The fix is to have unbundled apps initialize under MacOS 10.13 as under earlier OS, thus the new initialization procedure introduced for 10.13 is for bundled apps only. Tested OK on 10.13.6 and 10.14 public beta 10. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@13050 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
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]