Skip to content

Commit 4b3b9d9

Browse files
gujjwal00bk138
authored andcommitted
Libvncserver: Enable ExtendedClipboard encoding only when app signals support for UTF-8 cut-text
A UTF-8 capable client will usually prefer to send cut-text via ExtendedClipboard encoding once libvncserver declares support for it. If app doesn't assign a setXCutTextUTF8() callback, the default handler is used which is no-op. So client-to-server clipboard transfer will not work. Re: #638
1 parent 5279158 commit 4b3b9d9

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

include/rfb/rfb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ typedef struct _rfbScreenInfo
370370
uintptr_t listener_thread;
371371
#endif
372372
#ifdef LIBVNCSERVER_HAVE_LIBZ
373+
/** This is called when UTF-8 cut-text is received from a client.
374+
* Set this callback to enable ExtendedClipboard support. */
373375
rfbSetXCutTextUTF8ProcPtr setXCutTextUTF8;
374376
#endif
375377
/* Timeout value for select() calls, mainly used for multithreaded servers. */

src/libvncserver/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
10411041
screen->ptrAddEvent = rfbDefaultPtrAddEvent;
10421042
screen->setXCutText = rfbDefaultSetXCutText;
10431043
#ifdef LIBVNCSERVER_HAVE_LIBZ
1044-
screen->setXCutTextUTF8 = rfbDefaultSetXCutText;
1044+
screen->setXCutTextUTF8 = NULL;
10451045
#endif
10461046
screen->getCursorPtr = rfbDefaultGetCursorPtr;
10471047
screen->setTranslateFunction = rfbSetTranslateFunction;

src/libvncserver/rfbserver.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,7 @@ rfbProcessExtendedServerCutTextData(rfbClientPtr cl, uint32_t flags, const char
21932193
}
21942194
if (i == 0) {
21952195
/* text */
2196-
if (!cl->viewOnly) {
2196+
if (!cl->viewOnly && cl->screen->setXCutTextUTF8) {
21972197
cl->screen->setXCutTextUTF8(buf, size, cl);
21982198
}
21992199
}
@@ -2465,14 +2465,16 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
24652465
break;
24662466
#ifdef LIBVNCSERVER_HAVE_LIBZ
24672467
case rfbEncodingExtendedClipboard:
2468-
if (!cl->enableExtendedClipboard) {
2469-
rfbLog("Enabling ExtendedClipboard extension for client "
2470-
"%s\n", cl->host);
2471-
cl->enableExtendedClipboard = TRUE;
2472-
}
2473-
/* send the capabilities we support, currently only text */
2474-
if (!rfbSendExtendedClipboardCapability(cl)) {
2475-
return;
2468+
if (cl->screen->setXCutTextUTF8) {
2469+
if (!cl->enableExtendedClipboard) {
2470+
rfbLog("Enabling ExtendedClipboard extension for client "
2471+
"%s\n", cl->host);
2472+
cl->enableExtendedClipboard = TRUE;
2473+
}
2474+
/* send the capabilities we support, currently only text */
2475+
if (!rfbSendExtendedClipboardCapability(cl)) {
2476+
return;
2477+
}
24762478
}
24772479
break;
24782480
#endif

0 commit comments

Comments
 (0)