diff --git a/CMakeLists.txt b/CMakeLists.txt index be886bb8..fa543418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,12 +252,10 @@ if (_GLFW_X11) # Check for Xinerama (legacy multi-monitor support) if (NOT X11_Xinerama_FOUND) - message(FATAL_ERROR "The Xinerama library and headers were not found") + message(FATAL_ERROR "The Xinerama headers were not found") endif() list(APPEND glfw_INCLUDE_DIRS "${X11_Xinerama_INCLUDE_PATH}") - list(APPEND glfw_LIBRARIES "${X11_Xinerama_LIB}") - list(APPEND glfw_PKG_DEPS "xinerama") # Check for Xkb (X keyboard extension) if (NOT X11_Xkb_FOUND) diff --git a/src/x11_init.c b/src/x11_init.c index 6e06fb2e..90f5e34c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -593,12 +593,23 @@ static GLFWbool initExtensions(void) RROutputChangeNotifyMask); } - if (XineramaQueryExtension(_glfw.x11.display, - &_glfw.x11.xinerama.major, - &_glfw.x11.xinerama.minor)) + _glfw.x11.xinerama.handle = dlopen("libXinerama.so.1", RTLD_LAZY | RTLD_GLOBAL); + if (_glfw.x11.xinerama.handle) { - if (XineramaIsActive(_glfw.x11.display)) - _glfw.x11.xinerama.available = GLFW_TRUE; + _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive) + dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive"); + _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension) + dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension"); + _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens) + dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens"); + + if (XineramaQueryExtension(_glfw.x11.display, + &_glfw.x11.xinerama.major, + &_glfw.x11.xinerama.minor)) + { + if (XineramaIsActive(_glfw.x11.display)) + _glfw.x11.xinerama.available = GLFW_TRUE; + } } _glfw.x11.xkb.major = 1; @@ -883,6 +894,12 @@ void _glfwPlatformTerminate(void) _glfw.x11.randr.handle = NULL; } + if (_glfw.x11.xinerama.handle) + { + dlclose(_glfw.x11.xinerama.handle); + _glfw.x11.xinerama.handle = NULL; + } + if (_glfw.x11.helperWindowHandle) { if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) == diff --git a/src/x11_platform.h b/src/x11_platform.h index c0efb41d..05a6def8 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -82,6 +82,13 @@ typedef int (* PFN_XRRUpdateConfiguration)(XEvent*); #define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma #define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration +typedef Bool (* PFN_XineramaIsActive)(Display*); +typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*); +typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*); +#define XineramaIsActive _glfw.x11.xinerama.IsActive +#define XineramaQueryExtension _glfw.x11.xinerama.QueryExtension +#define XineramaQueryScreens _glfw.x11.xinerama.QueryScreens + typedef XID xcb_window_t; typedef XID xcb_visualid_t; typedef struct xcb_connection_t xcb_connection_t; @@ -314,8 +321,12 @@ typedef struct _GLFWlibraryX11 struct { GLFWbool available; + void* handle; int major; int minor; + PFN_XineramaIsActive IsActive; + PFN_XineramaQueryExtension QueryExtension; + PFN_XineramaQueryScreens QueryScreens; } xinerama; struct {