From 77e5a5c11ae4d00a6ffe96c3334ea9906fc0fc78 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 2 Apr 2016 07:03:18 +0000 Subject: Move get_carbon_function() to the Fl_Darwin_System_Driver class where it belongs. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11501 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Darwin/Fl_Darwin_System_Driver.H | 1 + src/drivers/Darwin/Fl_Darwin_System_Driver.cxx | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'src/drivers/Darwin') 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 #endif #include +#include 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$". // -- cgit v1.2.3