x0vncserver Clipboard Support

160 views
Skip to first unread message

Ankush Patel

unread,
Mar 24, 2023, 6:38:30 PM3/24/23
to TigerVNC Developer Discussion
Hi,

I am hoping to get the shared clipboard between the client and server functional when using x0vncserver. 

The only reference I can find to clipboard support in x0vncserver is this issue on Github: https://github.com/TigerVNC/tigervnc/issues/529

Taking a look at the method presented in that discussion, I can see the method signature has now changed to the following (in the file "unix/x0vncserver/XDesktop.cxx"):

void XDesktop::clientCutText(const char* /*str*/) {
}

There is also the following definition of the method in "common/rfb/SConnection.cxx":

void SConnection::clientCutText(const char* str)
{
  hasLocalClipboard = false;

  clientClipboard = latin1ToUTF8(str);
  hasRemoteClipboard = true;

  handleClipboardAnnounce(true);
}

However, this method does not seem to be called when using x0vncserver (based on placing a breakpoint on the method, connecting to the server and copying text on the client).

I would appreciate if anyone has any more information on what methods need to be implemented in order for x0vncserver to synchronise clipboards between the server and client.

Thank you. 

Pierre Ossman

unread,
Mar 25, 2023, 6:39:36 AM3/25/23
to Ankush Patel, TigerVNC Developer Discussion
On 24/03/2023 23:38, Ankush Patel wrote:
> Hi,
>
> I am hoping to get the shared clipboard between the client and server
> functional when using x0vncserver.
>
> The only reference I can find to clipboard support in x0vncserver is this
> issue on Github: https://github.com/TigerVNC/tigervnc/issues/529
>
> Taking a look at the method presented in that discussion, I can see the
> method signature has now changed to the following (in the file
> "unix/x0vncserver/XDesktop.cxx"):
>
> *void XDesktop::clientCutText(const char* /*str*/) {}*
>

That method is vestigial and should have been removed.

I suggest looking at the implementation for Xvnc for some idea of what
needs to be done. Basically everything in the file
unix/server/hw/vnc/vncSelection.c. That method would need to be ported
to regular X11 calls.

Regards
--
Pierre Ossman Software Development
Cendio AB http://cendio.com
Teknikringen 8 http://twitter.com/ThinLinc
583 30 Linköping http://facebook.com/ThinLinc
Phone: +46-13-214600

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Ankush Patel

unread,
Mar 26, 2023, 7:14:18 PM3/26/23
to TigerVNC Developer Discussion
Thanks for your response. 

I believe the first method I need to implement is VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client, bool available) 
Placing breakpoints on this method, I can see that the available argument is always false.

Based on the information you provided, the code in unix/xserver/hw/vnc/vncSelection.c in the void vncHandleClipboardAnnounce(int available) function 
grabs ownership of the clipboard only when available is set to true. Is there a reason the available argument is always set to false in x0vncserver?

Thanks,

Ankush.

Pierre Ossman

unread,
Mar 27, 2023, 1:45:14 AM3/27/23
to Ankush Patel, TigerVNC Developer Discussion
On 27/03/2023 01:14, Ankush Patel wrote:
> Thanks for your response.
>
> I believe the first method I need to implement is *VNCServerST::handleClipboardAnnounce(VNCSConnectionST*
> client, bool available) *
> Placing breakpoints on this method, I can see that the *available* argument
> is always *false.*
>
> Based on the information you provided, the code in
> *unix/xserver/hw/vnc/vncSelection.c* in the *void
> vncHandleClipboardAnnounce(int available)* function
> grabs ownership of the clipboard only when *available* is set to true. Is
> there a reason the *available* argument is always set to false in
> x0vncserver?
>

It should be the same behaviour as in Xvnc, so it should be set to true
whenever the client makes the clipboard available. I'm afraid you'll
have to debug further if you are seeing some issue with that.

Ankush Patel

unread,
Apr 1, 2023, 3:10:21 AM4/1/23
to TigerVNC Developer Discussion
I have confirmed what you said above is true - available does in fact go to true once the client on the remote recovers focus after copying from the remote. 

The source file in "common/rfb/VNCServerST.cxx" does not include the X11 header files, and attempting to include them results in compiler errors due to name collisions with the "Rect" in the rfb namespace.
Is this  the correct file to be implementing these X11 calls in (based on the Xvnc code)? 

Or is the correct approach to override the following methods from the SDesktop class in the XDesktop class (which includes some X11 headers) ?

virtual void handleClipboardRequest() {}
virtual void handleClipboardAnnounce(bool /*available*/) {}
virtual void handleClipboardData(const char* /*data*/) {}


Thank you once again,

Ankush.

Pierre Ossman

unread,
Apr 3, 2023, 1:52:41 AM4/3/23
to Ankush Patel, TigerVNC Developer Discussion
On 01/04/2023 09:10, Ankush Patel wrote:
> The source file in "common/rfb/VNCServerST.cxx" does not include the X11
> header files, and attempting to include them results in compiler errors due
> to name collisions with the "Rect" in the rfb namespace.
> Is this the correct file to be implementing these X11 calls in (based on
> the Xvnc code)?
>
> Or is the correct approach to override the following methods from the
> SDesktop class in the XDesktop class (which includes some X11 headers) ?
>
> virtual void handleClipboardRequest() {}
> virtual void handleClipboardAnnounce(bool /*available*/) {}
> virtual void handleClipboardData(const char* /*data*/) {}
>

The latter. Platform specific code (such as X11) should never be used in
the common/ directory.
Reply all
Reply to author
Forward
0 new messages