xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.

Version 26 (modified by Antoine Martin, 5 years ago) (diff)





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)
  • on OSX, we have to use polling to see client-side changes (see #11)
  • 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:

  • GTK_Clipboard_Test.exe on win32
  • gtk_view_clipboard.py on posix

see #272 comment:5 for screenshots and help with this tool.

Useful Pointers

Here are some pointers:

And here is a good quote from it:

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.clipboard_base - the base class for clipboard implementations
  • 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
  • #812 re-implement clipboard without gtk or nested main
  • #1167 tray menu clipboard choice irreversible
  • #1139 XPRA - Matlab - Clipboard blinking, UI unresponsive
  • #966 provide a persistent setting to select the default clipboard to synchronize
  • #1112 clipboard notification flashing constantly
  • #1018 recursion depth error
  • #883 Pasting into WYSIWYG editors rich text fails and causes too many clipboard requests
  • #842 html5 client clipboard support
  • #834 Sync issue with win32 client clipboard
  • #823 Session hangs and dies
  • #877 clipboard hitting maximum requests per second limit
  • #735 Clipboard working incorrect with java-applications (x2go + xpra)
  • #703 Copying URL from web browser address bar on remote host fails
  • #272 win32 multiple clipboards enhancement
  • #318 osx client-to-server clipboard support
  • #273 handle more clipboard formats
  • #274 advanced clipboard filtering
  • #275 handle clipboard large data transfers better
  • #276 limit clipboard direction
  • #452 detect and avoid creating clipboard loops
  • #313 speedup paste
  • #184 clipboard related bug, clipboard can fire at any time... so bugs may appear to come from somewhere else when in fact it is the clipboard that is the source of the problem - to keep in mind
  • #162 very hard to reproduce bug - relied on the list (and their order) of X11 atoms defined, as we tried to parse invalid values as X11 atoms
  • #176 32-bit vs 64-bit structures issue
  • #156 we drop clipboard packets that are too big - rather than causing network problems (bug was that we dropped the connection instead - oops!)
  • #52 another atom name issue, this time with Java apps
  • #8, #84 and #99 (dupe: #104): more clipboard atom problems
  • #11 win32 and osx clipboard ticket (old)