Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libvncserver: Enable ExtendedClipboard encoding only when app signals support for UTF-8 cut-text #639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/rfb/rfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ typedef struct _rfbScreenInfo
uintptr_t listener_thread;
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
/** This is called when UTF-8 cut-text is received from a client.
* Set this callback to enable ExtendedClipboard support. */
rfbSetXCutTextUTF8ProcPtr setXCutTextUTF8;
#endif
/* Timeout value for select() calls, mainly used for multithreaded servers. */
Expand Down
2 changes: 1 addition & 1 deletion src/libvncserver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
screen->ptrAddEvent = rfbDefaultPtrAddEvent;
screen->setXCutText = rfbDefaultSetXCutText;
#ifdef LIBVNCSERVER_HAVE_LIBZ
screen->setXCutTextUTF8 = rfbDefaultSetXCutText;
screen->setXCutTextUTF8 = NULL;
#endif
screen->getCursorPtr = rfbDefaultGetCursorPtr;
screen->setTranslateFunction = rfbSetTranslateFunction;
Expand Down
20 changes: 11 additions & 9 deletions src/libvncserver/rfbserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,7 @@ rfbProcessExtendedServerCutTextData(rfbClientPtr cl, uint32_t flags, const char
}
if (i == 0) {
/* text */
if (!cl->viewOnly) {
if (!cl->viewOnly && cl->screen->setXCutTextUTF8) {
cl->screen->setXCutTextUTF8(buf, size, cl);
}
}
Expand Down Expand Up @@ -2465,14 +2465,16 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
break;
#ifdef LIBVNCSERVER_HAVE_LIBZ
case rfbEncodingExtendedClipboard:
if (!cl->enableExtendedClipboard) {
rfbLog("Enabling ExtendedClipboard extension for client "
"%s\n", cl->host);
cl->enableExtendedClipboard = TRUE;
}
/* send the capabilities we support, currently only text */
if (!rfbSendExtendedClipboardCapability(cl)) {
return;
if (cl->screen->setXCutTextUTF8) {
if (!cl->enableExtendedClipboard) {
rfbLog("Enabling ExtendedClipboard extension for client "
"%s\n", cl->host);
cl->enableExtendedClipboard = TRUE;
}
/* send the capabilities we support, currently only text */
if (!rfbSendExtendedClipboardCapability(cl)) {
return;
}
}
break;
#endif
Expand Down
Loading