diff options
| author | Manolo Gouy <Manolo> | 2011-10-04 09:21:47 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2011-10-04 09:21:47 +0000 |
| commit | f309c395fc564de0e2799fa09e3d829ea1c5366a (patch) | |
| tree | 145665176a7cd04200dc008004663cded880fab7 /src | |
| parent | 5c7800ea61a14fde2417523d077010840cf67158 (diff) | |
STR#2600 again: under X11, dynamically load the libXrandr shared library.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9123 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_x.cxx | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 5b58a8ca3..3e3e24517 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -43,9 +43,13 @@ # include <X11/Xlocale.h> # include <X11/Xlib.h> # include <X11/keysym.h> -#if HAVE_XRANDR -#include <X11/extensions/Xrandr.h> -static int randrEventBase = -1; +#define USE_XRANDR 1 // means attempt to dynamically load libXrandr.so +#if USE_XRANDR +#include <dlfcn.h> +#define RRScreenChangeNotifyMask (1L << 0) // from X11/extensions/Xrandr.h +#define RRScreenChangeNotify 0 // from X11/extensions/Xrandr.h +static void *libxrandr_addr; // run-time address of libXrandr.so +static int randrEventBase; // base of RandR-defined events #endif static Fl_Xlib_Graphics_Driver fl_xlib_driver; @@ -642,11 +646,18 @@ void fl_open_display(Display* d) { #if !USE_COLORMAP Fl::visual(FL_RGB); #endif -#if HAVE_XRANDR - int error_base; - if (XRRQueryExtension(d, &randrEventBase, &error_base)) - XRRSelectInput(d, RootWindow(d, fl_screen), RRScreenChangeNotifyMask); - else randrEventBase = -1; +#if USE_XRANDR + libxrandr_addr = dlopen("libXrandr.so", RTLD_LAZY); + if (libxrandr_addr) { + int error_base; + typedef Bool (*XRRQueryExtension_type)(Display*, int*, int*); + typedef void (*XRRSelectInput_type)(Display*, Window, int); + XRRQueryExtension_type XRRQueryExtension_f = (XRRQueryExtension_type)dlsym(libxrandr_addr, "XRRQueryExtension"); + XRRSelectInput_type XRRSelectInput_f = (XRRSelectInput_type)dlsym(libxrandr_addr, "XRRSelectInput"); + if (XRRQueryExtension_f && XRRSelectInput_f && XRRQueryExtension_f(d, &randrEventBase, &error_base)) + XRRSelectInput_f(d, RootWindow(d, fl_screen), RRScreenChangeNotifyMask); + else libxrandr_addr = NULL; + } #endif } @@ -932,9 +943,8 @@ int fl_handle(const XEvent& thisevent) if ( XFilterEvent((XEvent *)&xevent, 0) ) return(1); -#if HAVE_XRANDR - if( randrEventBase >= 0 && xevent.type == randrEventBase + RRScreenChangeNotify) { - XRRUpdateConfiguration (&xevent); +#if USE_XRANDR + if( libxrandr_addr && xevent.type == randrEventBase + RRScreenChangeNotify) { Fl::call_screen_init(); fl_init_workarea(); Fl::handle(FL_SCREEN_CONFIGURATION_CHANGED, NULL); |
