Context Navigation

Clipboard

Introduction

This feature allows you to copy from outside the xpra session and paste inside it, and vice versa.
For various reasons, this doesn't always work quite as well as expected - see below for more details.

Configuration Options

clipboard-direction: (see #276) can be used to restrict the direction of the clipboard data flows. This setting is also available from the system tray menu.

clipboard-filter-file: can be used to filter out clipboard contents using regular expressions

local-clipboard / remote-clipboard: can be used to select which clipboard selection to synchronize with

Technical Constraints

Clipboard support is an ongoing struggle.

You must ensure that there is no other clipboard synchronization tool already running as this is very likely to interfere and cause loops.
In particular, avoid using the clipboard synchronization from your virtualization solution if you use one (ie: virtualbox, vmware, etc), or from tools like synergy. Alternatively, you can disable xpra's clipboard instead. Just avoid running both at the same time.

The most common platform specific issues are:

Mac OSX and MS Windows clients only have a single clipboard selection whereas X11 has three (CLIPBOARD, PRIMARY and SECONDARY), and therefore we need to choose which one to exchange with (see "local-clipboard" and "remote-clipboard" switches)

on MS Windows, the OS pulls clipboard data as soon as we claim ownership of the selection (see workaround in r3051 + r3075)

the HTML5 client can only access the clipboard when the browser decides it is appropriate to do so (usually following clicks or specific key combinations)

the xpra clibboard code is also problematic: the nested main loop code is known to cause serious problems on some platforms

Notes and Tuning

As noted in the wiki/FAQ, running a clipboard manager will interfere with the clipboard synchronization. At best, it will cause unnecessary traffic, at worst it can cause sluggishness and even crashes.

In order to prevent such issues, the code will automatically disable the clipboard if it looks like the synchronization is entering a loop.
You will see a message in the log output indicating:

clipboard disabled: more than 10 clipboard requests per second!

The maximum number of requests per second can be tuned setting the environment variable XPRA_CLIPBOARD_LIMIT to the desired value on the server. ie:

XPRA_CLIPBOARD_LIMIT=20 xpra start ...

Testing the clipboard

The easiest way to test the clipboard is to use xclip to set and verify the contents of each clipboard:

To set the "primary" clipboard contents to the string "_primary_":

echo _primary_ | xclip -i -selection primary

To print the contents of the "primary" clipboard:

xclip -o -selection primary

Note: on win32, you will need to change the clipboard currently in use to match the one you modify, this must be done before changing the value to ensure it is propagated.

Debugging: just add "-d clipboard" to your xpra command line.

We also ship a tool which can be used to diagnose clipboard behaviour:

Clipboard sharing and network transparency: It's nearly impossible to make the clipboard shared across different desktop computers. In fact it is possible, but such an implementation would be needlessly difficult and complex. The same can be said of support for virtualization (Qemu, Xen, VMWare). Sharing the clipboard between a virtual machine and the desktop itself is painfully difficult to implement correctly (in case X11 is running on the host operating system).

Source code

xpra.clipboard.gdk_clipboard - the gdk clipboard implementation (which requires Cython to build the C parts that allow us to access X11 atoms). It also contains the TranslatedClipboardProtocolHelper which is used by Windows clients to translate the local clipboard to a particular X11 clipboard.

Related tickets

#41: when we support concurrent users on the same session, we currently give the clipboard to the first client - doing anything else will be quite tricky