mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
X11: Add dynamic loading of libXcursor
This commit is contained in:
parent
3f852c321f
commit
99e72830ea
@ -266,12 +266,10 @@ if (_GLFW_X11)
|
||||
|
||||
# Check for Xcursor
|
||||
if (NOT X11_Xcursor_FOUND)
|
||||
message(FATAL_ERROR "The Xcursor libraries and headers were not found")
|
||||
message(FATAL_ERROR "The Xcursor headers were not found")
|
||||
endif()
|
||||
|
||||
list(APPEND glfw_INCLUDE_DIR "${X11_Xcursor_INCLUDE_PATH}")
|
||||
list(APPEND glfw_LIBRARIES "${X11_Xcursor_LIB}")
|
||||
list(APPEND glfw_PKG_DEPS "xcursor")
|
||||
|
||||
endif()
|
||||
|
||||
|
@ -593,6 +593,17 @@ static GLFWbool initExtensions(void)
|
||||
RROutputChangeNotifyMask);
|
||||
}
|
||||
|
||||
_glfw.x11.xcursor.handle = dlopen("libXcursor.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (_glfw.x11.xcursor.handle)
|
||||
{
|
||||
_glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
|
||||
dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate");
|
||||
_glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
|
||||
dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
|
||||
_glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
|
||||
dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
|
||||
}
|
||||
|
||||
_glfw.x11.xinerama.handle = dlopen("libXinerama.so.1", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (_glfw.x11.xinerama.handle)
|
||||
{
|
||||
@ -782,6 +793,9 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
|
||||
int i;
|
||||
Cursor cursor;
|
||||
|
||||
if (!_glfw.x11.xcursor.handle)
|
||||
return None;
|
||||
|
||||
XcursorImage* native = XcursorImageCreate(image->width, image->height);
|
||||
if (native == NULL)
|
||||
return None;
|
||||
@ -894,6 +908,12 @@ void _glfwPlatformTerminate(void)
|
||||
_glfw.x11.randr.handle = NULL;
|
||||
}
|
||||
|
||||
if (_glfw.x11.xcursor.handle)
|
||||
{
|
||||
dlclose(_glfw.x11.xcursor.handle);
|
||||
_glfw.x11.xcursor.handle = NULL;
|
||||
}
|
||||
|
||||
if (_glfw.x11.xinerama.handle)
|
||||
{
|
||||
dlclose(_glfw.x11.xinerama.handle);
|
||||
|
@ -82,6 +82,13 @@ typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
|
||||
#define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
|
||||
#define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration
|
||||
|
||||
typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
|
||||
typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
|
||||
typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
|
||||
#define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
|
||||
#define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
|
||||
#define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
|
||||
|
||||
typedef Bool (* PFN_XineramaIsActive)(Display*);
|
||||
typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
|
||||
typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*);
|
||||
@ -319,6 +326,13 @@ typedef struct _GLFWlibraryX11
|
||||
Atom format;
|
||||
} xdnd;
|
||||
|
||||
struct {
|
||||
void* handle;
|
||||
PFN_XcursorImageCreate ImageCreate;
|
||||
PFN_XcursorImageDestroy ImageDestroy;
|
||||
PFN_XcursorImageLoadCursor ImageLoadCursor;
|
||||
} xcursor;
|
||||
|
||||
struct {
|
||||
GLFWbool available;
|
||||
void* handle;
|
||||
|
Loading…
Reference in New Issue
Block a user