diff options
| author | Manolo Gouy <Manolo> | 2013-04-15 11:00:24 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2013-04-15 11:00:24 +0000 |
| commit | 4c97f14e8863e0a71f4d115ad20a8587a2af731e (patch) | |
| tree | eb18dd2f235e9dc3563bf1fc075f0bf21ce51bd9 /src | |
| parent | 62ae23272b9d4075c86360da46e51c8ec16859bd (diff) | |
Reduced the usage of global variables.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9878 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 5a9143e8f..08671695b 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -91,9 +91,7 @@ static Fl_Region MacRegionMinusRect(Fl_Region r, int x,int y,int w,int h); 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,19 +922,6 @@ static void cocoaMouseHandler(NSEvent *theEvent) } @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 @@ -1091,6 +1076,7 @@ void fl_open_callback(void (*cb)(const char *)) { #endif { BOOL seen_open_file; + void (*open_cb)(const char*); } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender; - (void)applicationDidBecomeActive:(NSNotification *)notify; @@ -1100,6 +1086,7 @@ void fl_open_callback(void (*cb)(const char *)) { - (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 @@ void fl_open_callback(void (*cb)(const char *)) { // 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 { |
