diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 011b239c..d4daa1f5 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -442,6 +442,13 @@ GLFWAPI void glfwSetX11SelectionString(const char* string); * @ingroup native */ GLFWAPI const char* glfwGetX11SelectionString(void); + +#include +extern void (*handleSelectionRequest)(XEvent*); +void (*getSelectionRequestHandler(void))(XEvent*); +void setSelectionRequestHandler(void (*handler)(XEvent*)); +Display* getGLFWDisplay(void); + #endif #if defined(GLFW_EXPOSE_NATIVE_GLX) diff --git a/src/x11_init.c b/src/x11_init.c index 982c526c..33b827af 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1314,6 +1314,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) _glfw.x11.xlib.handle = module; *platform = x11; + + handleSelectionRequest = handleSelectionRequest_; return GLFW_TRUE; } diff --git a/src/x11_platform.h b/src/x11_platform.h index 30326c5b..63fb893c 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -896,6 +896,8 @@ typedef struct _GLFWcursorX11 Cursor handle; } _GLFWcursorX11; +extern void (*handleSelectionRequest)(XEvent*); +void handleSelectionRequest_(XEvent* event); GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform); int _glfwInitX11(void); diff --git a/src/x11_window.c b/src/x11_window.c index 322349f0..787004d1 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -921,7 +921,8 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request) return None; } -static void handleSelectionRequest(XEvent* event) +void (*handleSelectionRequest)(XEvent*); +void handleSelectionRequest_(XEvent* event) { const XSelectionRequestEvent* request = &event->xselectionrequest; @@ -3356,6 +3357,15 @@ GLFWAPI const char* glfwGetX11SelectionString(void) return getSelectionString(_glfw.x11.PRIMARY); } +void (*getSelectionRequestHandler(void))(XEvent*) { + return handleSelectionRequest; +} +void setSelectionRequestHandler(void (*handler)(XEvent*)) { + handleSelectionRequest = handler; +} +Display* getGLFWDisplay(void) { + return _glfw.x11.display; +} #endif // _GLFW_X11