Author: manolo
Date: 2012-11-13 01:42:22 -0800 (Tue, 13 Nov 2012)
New Revision: 9717
Log:
Fix a Mac OS bug appeared with OS X 10.8: when a file is dragged on the 
application icon,
a delay of several seconds occur until the first application window opens.

Modified:
   branches/branch-3.0/src/fltk3/cocoa.mm

Modified: branches/branch-3.0/src/fltk3/cocoa.mm
===================================================================
--- branches/branch-3.0/src/fltk3/cocoa.mm      2012-11-13 09:34:54 UTC (rev 
9716)
+++ branches/branch-3.0/src/fltk3/cocoa.mm      2012-11-13 09:42:22 UTC (rev 
9717)
@@ -960,6 +960,9 @@
 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
 <NSWindowDelegate, NSApplicationDelegate>
 #endif
+{
+  BOOL seen_open_file;
+}
 - (void)windowDidMove:(NSNotification *)notif;
 - (void)windowDidResize:(NSNotification *)notif;
 - (void)windowDidResignKey:(NSNotification *)notif;
@@ -977,6 +980,7 @@
 - (void)applicationWillUnhide:(NSNotification *)notify;
 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client;
 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString 
*)filename;
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
 @end
 @implementation FLDelegate
 - (void)windowDidMove:(NSNotification *)notif
@@ -1231,6 +1235,7 @@
 }
 - (BOOL)application:(NSApplication *)theApplication openFile:(NSString 
*)filename
 {
+  seen_open_file = YES;
   if (open_cb) {
     fl_lock_function();
     (*open_cb)([filename UTF8String]);
@@ -1239,6 +1244,12 @@
   }
   return NO;
 }
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+  // without this, the opening of the 1st window is delayed by several seconds
+  // under Mac OS 10.8 when a file is dragged on the application icon
+  if (fl_mac_os_version >= 100800 && seen_open_file) [[NSApp mainWindow] 
orderFront:self];
+}
 @end
 
 @implementation FLApplication

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to