From 7a8771d3c46bef65e8432554bba8387188c99f3c Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 7 Feb 2023 12:47:42 +0100 Subject: [PATCH] macOS+XQuartz: support new homebrew name for GTK2 shared lib --- src/drivers/Posix/Fl_Posix_System_Driver.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx index 6d5231365..c4f2dc63c 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx +++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx @@ -230,6 +230,10 @@ void *Fl_Posix_System_Driver::dlopen_or_dlsym(const char *lib_name, const char * if (!lib_address) { snprintf(path, FL_PATH_MAX, "/sw/lib/%s.dylib", lib_name); lib_address = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); + // the GTK2 shared lib has a new name under homebrew in macOS, try it: + if (!lib_address && !strcmp(lib_name, "libgtk-x11-2.0")) { + lib_address = dlopen("/opt/homebrew/lib/libgtkmacintegration-gtk2.dylib", RTLD_LAZY | RTLD_GLOBAL); + } } } } @@ -262,13 +266,7 @@ bool Fl_Posix_System_Driver::probe_for_GTK(int major, int minor, void **p_ptr_gt #endif } else { // Try then with GTK2 - Fl_Posix_System_Driver::ptr_gtk = Fl_Posix_System_Driver::dlopen_or_dlsym( -#ifdef __APPLE__ - "libgtkmacintegration-gtk2" -#else - "libgtk-x11-2.0" -#endif - ); + Fl_Posix_System_Driver::ptr_gtk = Fl_Posix_System_Driver::dlopen_or_dlsym("libgtk-x11-2.0"); #ifdef DEBUG if (Fl_Posix_System_Driver::ptr_gtk) { puts("selected GTK-2\n");