Restore to commit f2424bf.

There remains a mysterious difference when dropping a file on an app icon
under macOS 26 between an app built with Xcode and one built with CMake.
This commit is contained in:
ManoloFLTK 2026-02-26 11:38:19 +01:00
parent 33f29ae481
commit 47b9156ac7

View File

@ -1716,19 +1716,12 @@ static void drain_dropped_files_list() {
free(fname); free(fname);
} }
static BOOL need_new_nsapp = NO;
/* /*
* Install an open documents event handler... * Install an open documents event handler...
*/ */
void Fl_Darwin_System_Driver::open_callback(void (*cb)(const char *)) { void Fl_Darwin_System_Driver::open_callback(void (*cb)(const char *)) {
if (!NSApp) { fl_open_display();
need_new_nsapp = YES; ((FLAppDelegate*)[NSApp delegate])->open_cb = cb;
[NSApplication sharedApplication];
}
FLAppDelegate *delegate = [FLAppDelegate alloc];
[NSApp setDelegate:[delegate init]];
delegate->open_cb = cb;
} }
@implementation FLApplication @implementation FLApplication
@ -1809,21 +1802,14 @@ void Fl_Cocoa_Screen_Driver::open_display_platform() {
if ( !beenHereDoneThat ) { if ( !beenHereDoneThat ) {
beenHereDoneThat = 1; beenHereDoneThat = 1;
if (!NSApp) { BOOL need_new_nsapp = (NSApp == nil);
need_new_nsapp = YES; if (need_new_nsapp) [NSApplication sharedApplication];
[NSApplication sharedApplication];
}
NSAutoreleasePool *localPool; NSAutoreleasePool *localPool;
localPool = [[NSAutoreleasePool alloc] init]; // never released localPool = [[NSAutoreleasePool alloc] init]; // never released
FLAppDelegate *delegate = [NSApp delegate]; FLAppDelegate *delegate = [FLAppDelegate alloc];
if (!delegate) { [(NSApplication*)NSApp setDelegate:[delegate init]];
delegate = [FLAppDelegate alloc];
[(NSApplication*)NSApp setDelegate:[delegate init]];
}
if (need_new_nsapp) { if (need_new_nsapp) {
if (fl_mac_os_version >= 101300 && if (fl_mac_os_version >= 101300 && fl_mac_os_version < 140000 && is_bundled()) {
(fl_mac_os_version < 140000 || (![NSApp isRunning] && delegate->open_cb)) &&
is_bundled()) {
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
in_nsapp_run = true; in_nsapp_run = true;
[NSApp run]; [NSApp run];