Hooks to allow serving non-text selections

This commit is contained in:
Alex Sanchez-Stern 2024-10-03 13:01:59 -07:00
parent b35641f4a3
commit f1f869acf7
4 changed files with 22 additions and 1 deletions

View File

@ -442,6 +442,13 @@ GLFWAPI void glfwSetX11SelectionString(const char* string);
* @ingroup native
*/
GLFWAPI const char* glfwGetX11SelectionString(void);
#include <X11/Xlib.h>
extern void (*handleSelectionRequest)(XEvent*);
void (*getSelectionRequestHandler(void))(XEvent*);
void setSelectionRequestHandler(void (*handler)(XEvent*));
Display* getGLFWDisplay(void);
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)

View File

@ -1314,6 +1314,8 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform)
_glfw.x11.xlib.handle = module;
*platform = x11;
handleSelectionRequest = handleSelectionRequest_;
return GLFW_TRUE;
}

View File

@ -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);

View File

@ -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