Author: manolo
Date: 2013-04-15 04:00:24 -0700 (Mon, 15 Apr 2013)
New Revision: 9878
Log:
Reduced the usage of global variables.
Modified:
branches/branch-1.3/src/Fl_cocoa.mm
Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2013-04-12 23:30:55 UTC (rev 9877)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2013-04-15 11:00:24 UTC (rev 9878)
@@ -91,9 +91,7 @@
static void cocoaMouseHandler(NSEvent *theEvent);
static int calc_mac_os_version();
-static Fl_Quartz_Graphics_Driver fl_quartz_driver;
-static Fl_Display_Device fl_quartz_display(&fl_quartz_driver);
-Fl_Display_Device *Fl_Display_Device::_display = &fl_quartz_display; // the
platform display
+Fl_Display_Device *Fl_Display_Device::_display = new Fl_Display_Device(new
Fl_Quartz_Graphics_Driver); // the platform display
// public variables
CGContextRef fl_gc = 0;
@@ -924,20 +922,7 @@
}
@end
-/*
- * Open callback function to call...
- */
-static void (*open_cb)(const char *) = 0;
-/*
- * Install an open documents event handler...
- */
-void fl_open_callback(void (*cb)(const char *)) {
- fl_open_display();
- open_cb = cb;
-}
-
-
@interface FLWindowDelegate : NSObject
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
<NSWindowDelegate>
@@ -1091,6 +1076,7 @@
#endif
{
BOOL seen_open_file;
+ void (*open_cb)(const char*);
}
-
(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
- (void)applicationDidBecomeActive:(NSNotification *)notify;
@@ -1100,6 +1086,7 @@
- (void)applicationWillUnhide:(NSNotification *)notify;
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString
*)filename;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
+- (void)open_cb:(void (*)(const char*))cb;
@end
@implementation FLAppDelegate
-
(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
@@ -1250,8 +1237,20 @@
// 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];
}
+- (void)open_cb:(void (*)(const char*))cb
+{
+ open_cb = cb;
+}
@end
+/*
+ * Install an open documents event handler...
+ */
+void fl_open_callback(void (*cb)(const char *)) {
+ fl_open_display();
+ [[NSApp delegate] open_cb:cb];
+}
+
@implementation FLApplication
+ (void)sendEvent:(NSEvent *)theEvent
{
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit