Package: ssvnc Version: 1.0.29-3 Severity: normal For some time I've noticed my clipboard being corrupted during VNC sessions between GNU/Linux machines with x11vnc server and ssvncviewer - clipboard contents would be overwritten or changes would apparently not be picked up on one or other side on occasion. After discovering and disabling the PRIMARY mess (...), I found that even with the following call, clipboard updates from my main machine didn't always reach the other end:
========================================================== ssvncviewer -recvtext 'clipboard' -sendclipboard omega3:0 ========================================================== If I copied some text on the ssvncviewer machine and then changed the selection before I move to the VNC window, the selection (i.e. the PRIMARY) would end up sent to the other machine's clipboard, even when expressly told not to (x11vnc is also launched with '-noprimary -nosetprimary'). vncviewer/selection.c:SelectionFromVNC has logic to detect when '-sendclipboard' is specified (via sendsel and appData.sendClipboard), however when '-sendalways' is not used, GetSelectionTimeCallback is called. When GetSelectionTimeCallback decides a selection change has occurred, it calls XtGetSelectionValue with the hardcoded XA_PRIMARY selection, which causes the bug. In the attached patch I have copied the logic from SelectionToVNC to use the configured selection. For a user workaround, launch ssvncviewer with '-sendclipboard -sendalways', as you don't get the extra callback and only one XtGetSelectionValue fetch is used with the correct selection (but now every time you hover over the VNC window you spam the other end with clipboard 'updates'). --- System information. --- Architecture: amd64 Kernel: Linux 4.7.0-1-amd64 Devuan Release: stretch/sid 990 testing 10.1.0.3 500 quodlibet-unstable lazka.github.io --- Package information. --- Depends (Version) | Installed ================================-+-============= libc6 (>= 2.14) | libice6 (>= 1:1.0.0) | libjpeg62-turbo (>= 1.3.1) | libsm6 | libssl1.0.2 (>= 1.0.2d) | libx11-6 | libxaw7 | libxext6 | libxmu6 | libxpm4 | libxt6 | zlib1g (>= 1:1.1.4) | tk | openssh-client | bind9-host | OR host | procps | psmisc | xterm | stunnel4 | openssl | Recommends (Version) | Installed ============================-+-=========== default-jre | 2:1.8-57 OR java5-runtime | Package's Suggests field is empty.
diff --git a/vnc_unixsrc/vncviewer/selection.c b/vnc_unixsrc/vncviewer/selection.c index 48b0a98..beb6916 100644 --- a/vnc_unixsrc/vncviewer/selection.c +++ b/vnc_unixsrc/vncviewer/selection.c @@ -199,12 +199,18 @@ GetSelectionTimeCallback(Widget w, XtPointer clientData, Atom* selection, Atom* type, XtPointer value, unsigned long* length, int* format) { + Atom sendsel = XA_PRIMARY; + + if (appData.sendClipboard && clipboard_atom != None) { + sendsel = clipboard_atom; + } + if (value && *format == 32 && *length == 1) { Time t = *(CARD32 *)value; if (TIME_LATER(t, prevSelectionTime)) { prevSelectionTime = t; - XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, GetSelectionCallback, NULL, CurrentTime); + XtGetSelectionValue(w, sendsel, XA_STRING, GetSelectionCallback, NULL, CurrentTime); } } else if (!getenv("VNCVIEWER_NO_CUTBUFFER")) { if (TIME_LATER(cutBufferTime, prevSelectionTime)) {
signature.asc
Description: OpenPGP digital signature