From 822eb1c986d3cc026615b6acb79f05fa4cd4f226 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 29 Apr 2013 12:26:25 +0200 Subject: [PATCH] Added support for MULTIPLE target. --- src/x11_clipboard.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ src/x11_init.c | 1 + src/x11_platform.h | 1 + 3 files changed, 53 insertions(+) diff --git a/src/x11_clipboard.c b/src/x11_clipboard.c index 579d2a20..87015af0 100644 --- a/src/x11_clipboard.c +++ b/src/x11_clipboard.c @@ -67,6 +67,57 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request) return request->property; } + if (request->target == _glfw.x11.MULTIPLE) + { + // Multiple conversions were requested + + Atom* targets; + unsigned long i, count; + + count = _glfwGetWindowProperty(request->requestor, + request->property, + XA_ATOM, + (unsigned char**) &targets); + + for (i = 0; i < count; i += 2) + { + int j; + + for (j = 0; j < _GLFW_CLIPBOARD_FORMAT_COUNT; j++) + { + if (targets[i] == _glfw.x11.selection.formats[j]) + break; + } + + if (j < _GLFW_CLIPBOARD_FORMAT_COUNT) + { + XChangeProperty(_glfw.x11.display, + request->requestor, + targets[i + 1], + targets[i], + 8, + PropModeReplace, + (unsigned char*) _glfw.x11.selection.string, + strlen(_glfw.x11.selection.string)); + } + else + targets[i + 1] = None; + } + + XChangeProperty(_glfw.x11.display, + request->requestor, + request->property, + request->target, + 32, + PropModeReplace, + (unsigned char*) targets, + count); + + XFree(targets); + + return request->property; + } + for (i = 0; i < _GLFW_CLIPBOARD_FORMAT_COUNT; i++) { if (request->target == _glfw.x11.selection.formats[i]) diff --git a/src/x11_init.c b/src/x11_init.c index 9f706efb..2c403540 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -544,6 +544,7 @@ static GLboolean initDisplay(void) // Find or create standard clipboard atoms _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False); + _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False); _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False); // Store clipboard format atoms in order of preference diff --git a/src/x11_platform.h b/src/x11_platform.h index e5b2b547..5a843973 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -119,6 +119,7 @@ typedef struct _GLFWlibraryX11 // Selection atoms Atom TARGETS; + Atom MULTIPLE; Atom CLIPBOARD; Atom UTF8_STRING; Atom COMPOUND_STRING;