diff options
| -rw-r--r-- | FL/mac.H | 1 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 21 | ||||
| -rw-r--r-- | src/Fl_get_key_mac.cxx | 3 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm | 11 | ||||
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 11 |
6 files changed, 25 insertions, 23 deletions
@@ -167,7 +167,6 @@ public: int set_cursor(const Fl_RGB_Image*, int, int); static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h); static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel); - static void *get_carbon_function(const char *name); static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // compute work area of a given screen static int next_marked_length; // next length of marked text after current marked text will have been replaced static const int CoreText_threshold; // Mac OS version from which the Core Text API is used to display text diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index baf4d9825..f73d90062 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -1813,13 +1813,13 @@ static int input_method_startup() if (retval == -1) { fl_open_display(); if (fl_mac_os_version >= 100500) { - TSMGetActiveDocument = (TSMGetActiveDocument_type)Fl_X::get_carbon_function("TSMGetActiveDocument"); - TSMSetDocumentProperty = (TSMSetDocumentProperty_type)Fl_X::get_carbon_function("TSMSetDocumentProperty"); - TSMRemoveDocumentProperty = (TSMRemoveDocumentProperty_type)Fl_X::get_carbon_function("TSMRemoveDocumentProperty"); - TISCreateASCIICapableInputSourceList = (TISCreateASCIICapableInputSourceList_type)Fl_X::get_carbon_function("TISCreateASCIICapableInputSourceList"); + TSMGetActiveDocument = (TSMGetActiveDocument_type)Fl_Darwin_System_Driver::get_carbon_function("TSMGetActiveDocument"); + TSMSetDocumentProperty = (TSMSetDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMSetDocumentProperty"); + TSMRemoveDocumentProperty = (TSMRemoveDocumentProperty_type)Fl_Darwin_System_Driver::get_carbon_function("TSMRemoveDocumentProperty"); + TISCreateASCIICapableInputSourceList = (TISCreateASCIICapableInputSourceList_type)Fl_Darwin_System_Driver::get_carbon_function("TISCreateASCIICapableInputSourceList"); retval = (TSMGetActiveDocument && TSMSetDocumentProperty && TSMRemoveDocumentProperty && TISCreateASCIICapableInputSourceList ? 1 : 0); } else { - KeyScript = (KeyScript_type)Fl_X::get_carbon_function("KeyScript"); + KeyScript = (KeyScript_type)Fl_Darwin_System_Driver::get_carbon_function("KeyScript"); retval = (KeyScript? 1 : 0); } } @@ -4331,17 +4331,6 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_Shared_Image*& top, CGContextRelease(auxgc); } - -/* Returns the address of a Carbon function after dynamically loading the Carbon library if needed. - Supports old Mac OS X versions that may use a couple of Carbon calls: - GetKeys used by OS X 10.3 or before (in Fl::get_key()) - PMSessionPageSetupDialog and PMSessionPrintDialog used by 10.4 or before (in Fl_Printer::start_job()) - */ -void *Fl_X::get_carbon_function(const char *function_name) { - static void *carbon = dlopen("/System/Library/Frameworks/Carbon.framework/Carbon", RTLD_LAZY); - return (carbon ? dlsym(carbon, function_name) : NULL); -} - /* Returns the version of the running Mac OS as an int such as 100802 for 10.8.2 */ int Fl_X::calc_mac_os_version() { diff --git a/src/Fl_get_key_mac.cxx b/src/Fl_get_key_mac.cxx index 358678015..02c657f1b 100644 --- a/src/Fl_get_key_mac.cxx +++ b/src/Fl_get_key_mac.cxx @@ -22,6 +22,7 @@ #include <FL/Fl.H> #include <FL/x.H> +#include "drivers/Darwin/Fl_Darwin_System_Driver.H" // The list of Mac OS virtual keycodes appears with OS 10.5 in // ...../Carbon.framework/Frameworks/HIToolbox.framework/Headers/Events.h @@ -254,7 +255,7 @@ int Fl::get_key(int k) { // use the GetKeys Carbon function typedef void (*keymap_f)(fl_KeyMap); static keymap_f f = NULL; - if (!f) f = ( keymap_f )Fl_X::get_carbon_function("GetKeys"); + if (!f) f = ( keymap_f )Fl_Darwin_System_Driver::get_carbon_function("GetKeys"); (*f)(foo); #ifdef MAC_TEST_FOR_KEYCODES static int cnt = 0; diff --git a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm index 188828da4..3c536ae7c 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm @@ -20,6 +20,7 @@ #include <FL/Fl_Shared_Image.H> #include <FL/Fl_Window_Driver.H> #include "../Quartz/Fl_Quartz_Printer_Graphics_Driver.H" +#include "../Darwin/Fl_Darwin_System_Driver.H" #include <FL/Fl.H> #include <FL/x.H> @@ -137,7 +138,7 @@ int Fl_Cocoa_Printer_Driver::start_job (int pagecount, int *frompage, int *topag // get pointer to the PMSessionPageSetupDialog Carbon function typedef OSStatus (*dialog_f)(PMPrintSession, PMPageFormat, Boolean *); static dialog_f f = NULL; - if (!f) f = (dialog_f)Fl_X::get_carbon_function("PMSessionPageSetupDialog"); + if (!f) f = (dialog_f)Fl_Darwin_System_Driver::get_carbon_function("PMSessionPageSetupDialog"); status = (*f)(printSession, pageFormat, &accepted); if (status != noErr || !accepted) { Fl::first_window()->show(); @@ -151,7 +152,7 @@ int Fl_Cocoa_Printer_Driver::start_job (int pagecount, int *frompage, int *topag // get pointer to the PMSessionPrintDialog Carbon function typedef OSStatus (*dialog_f2)(PMPrintSession, PMPrintSettings, PMPageFormat, Boolean *); static dialog_f2 f2 = NULL; - if (!f2) f2 = (dialog_f2)Fl_X::get_carbon_function("PMSessionPrintDialog"); + if (!f2) f2 = (dialog_f2)Fl_Darwin_System_Driver::get_carbon_function("PMSessionPrintDialog"); status = (*f2)(printSession, printSettings, pageFormat, &accepted); if (!accepted) status = kPMCancel; if (status != noErr) { @@ -168,11 +169,11 @@ int Fl_Cocoa_Printer_Driver::start_job (int pagecount, int *frompage, int *topag mystring[0] = kPMGraphicsContextCoreGraphics; CFArrayRef array = CFArrayCreate(NULL, (const void **)mystring, 1, &kCFTypeArrayCallBacks); PMSessionSetDocumentFormatGeneration_type PMSessionSetDocumentFormatGeneration = - (PMSessionSetDocumentFormatGeneration_type)Fl_X::get_carbon_function("PMSessionSetDocumentFormatGeneration"); + (PMSessionSetDocumentFormatGeneration_type)Fl_Darwin_System_Driver::get_carbon_function("PMSessionSetDocumentFormatGeneration"); status = PMSessionSetDocumentFormatGeneration(printSession, kPMDocumentFormatDefault, array, NULL); CFRelease(array); PMSessionBeginDocumentNoDialog_type PMSessionBeginDocumentNoDialog = - (PMSessionBeginDocumentNoDialog_type)Fl_X::get_carbon_function("PMSessionBeginDocumentNoDialog"); + (PMSessionBeginDocumentNoDialog_type)Fl_Darwin_System_Driver::get_carbon_function("PMSessionBeginDocumentNoDialog"); status = PMSessionBeginDocumentNoDialog(printSession, printSettings, pageFormat); #endif //__LP64__ } @@ -292,7 +293,7 @@ int Fl_Cocoa_Printer_Driver::start_page (void) { #if ! __LP64_ PMSessionGetGraphicsContext_type PMSessionGetGraphicsContext = - (PMSessionGetGraphicsContext_type)Fl_X::get_carbon_function("PMSessionGetGraphicsContext"); + (PMSessionGetGraphicsContext_type)Fl_Darwin_System_Driver::get_carbon_function("PMSessionGetGraphicsContext"); status = PMSessionGetGraphicsContext(printSession, NULL, (void **)&gc); #endif } diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.H b/src/drivers/Darwin/Fl_Darwin_System_Driver.H index 3ba7155b6..ab99c54d0 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.H +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.H @@ -63,6 +63,7 @@ public: virtual int rmdir(const char* f) {return ::rmdir(f);} virtual int rename(const char* f, const char *n) {return ::rename(f, n);} virtual int clocale_printf(FILE *output, const char *format, va_list args); + static void *get_carbon_function(const char *name); }; #endif // FL_DARWIN_SYSTEM_DRIVER_H diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx index 3740e55cf..450857652 100644 --- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx +++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx @@ -28,6 +28,7 @@ #include <locale.h> #endif #include <stdio.h> +#include <dlfcn.h> int Fl_X::next_marked_length = 0; @@ -79,6 +80,16 @@ int Fl_Darwin_System_Driver::clocale_printf(FILE *output, const char *format, va return retval; } +/* Returns the address of a Carbon function after dynamically loading the Carbon library if needed. + Supports old Mac OS X versions that may use a couple of Carbon calls: + GetKeys used by OS X 10.3 or before (in Fl::get_key()) + PMSessionPageSetupDialog and PMSessionPrintDialog used by 10.4 or before (in Fl_Printer::start_job()) + */ +void *Fl_Darwin_System_Driver::get_carbon_function(const char *function_name) { + static void *carbon = dlopen("/System/Library/Frameworks/Carbon.framework/Carbon", RTLD_LAZY); + return (carbon ? dlsym(carbon, function_name) : NULL); +} + // // End of "$Id$". // |
