From 2161fa2bd0f838be525d136a726aef088bc69292 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 15 Nov 2019 21:48:43 +0100 Subject: Clipboard.c: improve XChangeProperty code The previously used "Atom" type was confusing. Clarify this by writing the code as requested in the manpage of XChangeProperty: "If the specified format is 8, the property data must be a char array. If the specified format is 16, the property data must be a short array. If the specified format is 32, the property data must be a long array." --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 5f7bdab4e..10d98fe88 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -725,7 +725,7 @@ void nxagentRequestSelection(XEvent *X) * FIXME: these must be external Atoms! */ - Atom targets[] = {XA_STRING}; + long targets[] = {XA_STRING}; int numTargets = 1; #ifdef DEBUG @@ -743,7 +743,7 @@ void nxagentRequestSelection(XEvent *X) X->xselectionrequest.requestor, X->xselectionrequest.property, XInternAtom(nxagentDisplay, "ATOM", 0), - sizeof(Atom)*8, + 32, PropModeReplace, (unsigned char*)&targets, numTargets); -- cgit v1.2.3 From a41e23c062bc3401eb623d93c6589012244d7f6a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 15 Nov 2019 21:53:50 +0100 Subject: Clipboard.c: automatically calc the array size --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 10d98fe88..b04ab88c2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -726,7 +726,7 @@ void nxagentRequestSelection(XEvent *X) */ long targets[] = {XA_STRING}; - int numTargets = 1; + int numTargets = sizeof(targets) / sizeof(targets[0]); #ifdef DEBUG fprintf(stderr, "%s: available targets:\n", __func__); @@ -1702,7 +1702,7 @@ int nxagentConvertSelection(ClientPtr client, WindowPtr pWin, Atom selection, { /* --- Order changed by dimbor (prevent sending COMPOUND_TEXT to client --- */ Atom targets[] = {XA_STRING, clientUTF8_STRING, clientTEXT, clientCOMPOUND_TEXT}; - int numTargets = 4; + int numTargets = sizeof(targets) / sizeof(targets[0]); #ifdef DEBUG fprintf(stderr, "%s: available targets:\n", __func__); -- cgit v1.2.3 From 9681d039c51af0971f8bd5daa775e5a5856899e7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 15 Nov 2019 22:01:09 +0100 Subject: Clipboard: fix debugging output Correctly determine the Atom names from the real X server. --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index b04ab88c2..85c4702b9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -729,10 +729,16 @@ void nxagentRequestSelection(XEvent *X) int numTargets = sizeof(targets) / sizeof(targets[0]); #ifdef DEBUG - fprintf(stderr, "%s: available targets:\n", __func__); - for (int i = 0; i < numTargets; i++) - fprintf(stderr, "%s: %s\n", __func__, NameForAtom(targets[i])); - fprintf(stderr, "\n"); + { + fprintf(stderr, "%s: Sending %d available targets:\n", __func__, numTargets); + for (int i = 0; i < numTargets; i++) + { + char *s = XGetAtomName(nxagentDisplay, targets[i]); + fprintf(stderr, "%s: %ld %s\n", __func__, targets[i], s); + SAFE_XFree(s); + } + fprintf(stderr, "\n"); + } #endif /* -- cgit v1.2.3 From cfaf59728f0ff6ed5fe13f2093c89680943fa469 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 15 Nov 2019 22:04:11 +0100 Subject: Clipboard.c: report more supported targets fix one FIXME. This is a rewritten and extended version of a quick patch by Danil Pleshakov and Dimbor. --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index 85c4702b9..6ec30a3fb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -716,16 +716,15 @@ void nxagentRequestSelection(XEvent *X) * The selection does not matter here, we will return this for * PRIMARY and CLIPBOARD. * - * FIXME: shouldn't we support UTF8_STRING, too? * FIXME: I am wondering if we should align this with * nxagentConvertSelection, where we report more formats. * FIXME: the perfect solution should not just answer with * XA_STRING but ask the real owner what format it supports. The * should then be sent to the original requestor. - * FIXME: these must be external Atoms! + * FIXME: add serverCOMPOUND_TEXT? */ - long targets[] = {XA_STRING}; + long targets[] = {XA_STRING, serverUTF8_STRING, serverTEXT, serverTARGETS, serverTIMESTAMP}; int numTargets = sizeof(targets) / sizeof(targets[0]); #ifdef DEBUG -- cgit v1.2.3