Author: manolo
Date: 2011-10-04 05:55:52 -0700 (Tue, 04 Oct 2011)
New Revision: 9125
Log:
Backport from 1.3: load libXrand.so dynamic library at run time.

Modified:
   branches/branch-3.0/configure.in
   branches/branch-3.0/include/configh.in
   branches/branch-3.0/src/fltk3/x11.cxx

Modified: branches/branch-3.0/configure.in
===================================================================
--- branches/branch-3.0/configure.in    2011-10-04 09:31:42 UTC (rev 9124)
+++ branches/branch-3.0/configure.in    2011-10-04 12:55:52 UTC (rev 9125)
@@ -981,16 +981,6 @@
                 LIBS="-lXext $LIBS")
         fi
 
-       dnl Check for the XRandR extension unless disabled...
-        AC_ARG_ENABLE(xrandr, [  --enable-xrandr         turn on XRandR 
support [default=yes]])
-
-       if test x$enable_xrandr != xno; then
-           AC_CHECK_HEADER(X11/extensions/Xrandr.h, AC_DEFINE(HAVE_XRANDR),,
-               [#include <X11/Xlib.h>])
-           AC_CHECK_LIB(Xrandr, XRRQueryExtension,
-               LIBS="-lXrandr $LIBS")
-       fi
-
         dnl Check for overlay visuals...
         AC_PATH_PROG(XPROP, xprop)
         AC_CACHE_CHECK(for X overlay visuals, ac_cv_have_overlay,
@@ -1324,9 +1314,6 @@
         if test x$enable_xdbe != xno; then
             graphics="$graphics+Xdbe"
         fi
-       if test x$enable_xrandr != xno; then
-           graphics="$graphics+Xrandr"
-       fi
         if test x$enable_xinerama != xno; then
             graphics="$graphics+Xinerama"
         fi

Modified: branches/branch-3.0/include/configh.in
===================================================================
--- branches/branch-3.0/include/configh.in      2011-10-04 09:31:42 UTC (rev 
9124)
+++ branches/branch-3.0/include/configh.in      2011-10-04 12:55:52 UTC (rev 
9125)
@@ -93,14 +93,6 @@
 #define HAVE_XINERAMA 0
 
 /*
- * HAVE_XRANDR
- *
- * Do we have the Xrandr library to support runtime update of multi-head 
displays?
- */
-
-#define HAVE_XRANDR 0
-
-/*
  * USE_XFT
  *
  * Use the new Xft library to draw anti-aliased text.

Modified: branches/branch-3.0/src/fltk3/x11.cxx
===================================================================
--- branches/branch-3.0/src/fltk3/x11.cxx       2011-10-04 09:31:42 UTC (rev 
9124)
+++ branches/branch-3.0/src/fltk3/x11.cxx       2011-10-04 12:55:52 UTC (rev 
9125)
@@ -53,9 +53,13 @@
 #  include <X11/Xlocale.h>
 #  include <X11/Xlib.h>
 #  include <X11/keysym.h>
-#ifdef 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 fltk3::XlibGraphicsDriver fl_xlib_driver;
@@ -653,11 +657,18 @@
 #if !USE_COLORMAP
   fltk3::visual(fltk3::RGB);
 #endif
-#ifdef 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
 }
 
@@ -943,9 +954,8 @@
   if ( XFilterEvent((XEvent *)&xevent, 0) )
       return(1);
 
-#ifdef HAVE_XRANDR  
-  if( randrEventBase >= 0 && xevent.type == randrEventBase + 
RRScreenChangeNotify) {
-    XRRUpdateConfiguration (&xevent);
+#if USE_XRANDR  
+  if( libxrandr_addr && xevent.type == randrEventBase + RRScreenChangeNotify) {
     fltk3::call_screen_init();
     fl_init_workarea();
     fltk3::handle(fltk3::SCREEN_CONFIGURATION_CHANGED, NULL);

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to