aboutsummaryrefslogtreecommitdiffstats
path: root/unix/xserver
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2019-05-10 11:44:19 +0200
committerPierre Ossman <ossman@cendio.se>2019-07-01 11:18:27 +0200
commit5fbbe10b6c180ae8c0545695db6ad308cb5caea7 (patch)
treedb83c70816ef00328e0da860a5b40522ce6435ae /unix/xserver
parent615d16bd5ba11e89262cc5cfe94a35b6d6e7a628 (diff)
downloadtigervnc-5fbbe10b6c180ae8c0545695db6ad308cb5caea7.tar.gz
tigervnc-5fbbe10b6c180ae8c0545695db6ad308cb5caea7.zip
Use UTF-8 in clipboard API
In prepartion for better clipboard extensions that can send Unicode data between the client and server.
Diffstat (limited to 'unix/xserver')
-rw-r--r--unix/xserver/hw/vnc/vncSelection.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/unix/xserver/hw/vnc/vncSelection.c b/unix/xserver/hw/vnc/vncSelection.c
index 4fac50e2..5191bb94 100644
--- a/unix/xserver/hw/vnc/vncSelection.c
+++ b/unix/xserver/hw/vnc/vncSelection.c
@@ -362,23 +362,24 @@ static int vncConvertSelection(ClientPtr client, Atom selection,
return Success;
} else {
if ((target == xaSTRING) || (target == xaTEXT)) {
+ char* latin1;
+
+ latin1 = vncUTF8ToLatin1(data, (size_t)-1);
+ if (latin1 == NULL)
+ return BadAlloc;
+
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
XA_STRING, 8, PropModeReplace,
- strlen(data), (char*)data,
- TRUE);
+ strlen(latin1), latin1, TRUE);
+
+ vncStrFree(latin1);
+
if (rc != Success)
return rc;
} else if (target == xaUTF8_STRING) {
- char* buffer;
-
- buffer = vncLatin1ToUTF8(data, (size_t)-1);
- if (buffer == NULL)
- return BadAlloc;
-
rc = dixChangeWindowProperty(serverClient, pWin, realProperty,
xaUTF8_STRING, 8, PropModeReplace,
- strlen(buffer), buffer, TRUE);
- vncStrFree(buffer);
+ strlen(data), data, TRUE);
if (rc != Success)
return rc;
} else {
@@ -515,13 +516,14 @@ static void vncHandleSelection(Atom selection, Atom target,
vncAnnounceClipboard(TRUE);
}
} else {
- if (vncHasAtom(xaSTRING, (const Atom*)prop->data, prop->size))
- vncSelectionRequest(selection, xaSTRING);
- else if (vncHasAtom(xaUTF8_STRING, (const Atom*)prop->data, prop->size))
+ if (vncHasAtom(xaUTF8_STRING, (const Atom*)prop->data, prop->size))
vncSelectionRequest(selection, xaUTF8_STRING);
+ else if (vncHasAtom(xaSTRING, (const Atom*)prop->data, prop->size))
+ vncSelectionRequest(selection, xaSTRING);
}
} else if (target == xaSTRING) {
char* filtered;
+ char* utf8;
if (prop->format != 8)
return;
@@ -532,27 +534,26 @@ static void vncHandleSelection(Atom selection, Atom target,
if (filtered == NULL)
return;
+ utf8 = vncLatin1ToUTF8(filtered, (size_t)-1);
+ vncStrFree(filtered);
+ if (utf8 == NULL)
+ return;
+
LOG_DEBUG("Sending clipboard to clients (%d bytes)",
- (int)strlen(filtered));
+ (int)strlen(utf8));
- vncSendClipboardData(filtered);
+ vncSendClipboardData(utf8);
- vncStrFree(filtered);
+ vncStrFree(utf8);
} else if (target == xaUTF8_STRING) {
char *filtered;
- char* buffer;
if (prop->format != 8)
return;
if (prop->type != xaUTF8_STRING)
return;
- buffer = vncUTF8ToLatin1(prop->data, prop->size);
- if (buffer == NULL)
- return;
-
- filtered = vncConvertLF(buffer, (size_t)-1);
- vncStrFree(buffer);
+ filtered = vncConvertLF(prop->data, prop->size);
if (filtered == NULL)
return;