1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00

X11: Add dynamic loading of libXinerama

This commit is contained in:
Camilla Löwy 2017-08-16 19:55:32 +02:00
parent 15d102b75e
commit 3f852c321f
3 changed files with 34 additions and 8 deletions

View File

@ -252,12 +252,10 @@ if (_GLFW_X11)
# Check for Xinerama (legacy multi-monitor support) # Check for Xinerama (legacy multi-monitor support)
if (NOT X11_Xinerama_FOUND) 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() endif()
list(APPEND glfw_INCLUDE_DIRS "${X11_Xinerama_INCLUDE_PATH}") 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) # Check for Xkb (X keyboard extension)
if (NOT X11_Xkb_FOUND) if (NOT X11_Xkb_FOUND)

View File

@ -593,12 +593,23 @@ static GLFWbool initExtensions(void)
RROutputChangeNotifyMask); RROutputChangeNotifyMask);
} }
if (XineramaQueryExtension(_glfw.x11.display, _glfw.x11.xinerama.handle = dlopen("libXinerama.so.1", RTLD_LAZY | RTLD_GLOBAL);
&_glfw.x11.xinerama.major, if (_glfw.x11.xinerama.handle)
&_glfw.x11.xinerama.minor))
{ {
if (XineramaIsActive(_glfw.x11.display)) _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
_glfw.x11.xinerama.available = GLFW_TRUE; 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; _glfw.x11.xkb.major = 1;
@ -883,6 +894,12 @@ void _glfwPlatformTerminate(void)
_glfw.x11.randr.handle = NULL; _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 (_glfw.x11.helperWindowHandle)
{ {
if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) == if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==

View File

@ -82,6 +82,13 @@ typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
#define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma #define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
#define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration #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_window_t;
typedef XID xcb_visualid_t; typedef XID xcb_visualid_t;
typedef struct xcb_connection_t xcb_connection_t; typedef struct xcb_connection_t xcb_connection_t;
@ -314,8 +321,12 @@ typedef struct _GLFWlibraryX11
struct { struct {
GLFWbool available; GLFWbool available;
void* handle;
int major; int major;
int minor; int minor;
PFN_XineramaIsActive IsActive;
PFN_XineramaQueryExtension QueryExtension;
PFN_XineramaQueryScreens QueryScreens;
} xinerama; } xinerama;
struct { struct {