Clipboard
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.
Platform specific issues:
* Mac OSX and MS Windows clients only have a single clipboard selection whereas X11 has three: `CLIPBOARD`, `PRIMARY` and `SECONDARY`; therefore we need to choose which one to exchange with: see `local-clipboard` and `remote-clipboard` switches
* Mac OSX and MS Windows clients synchronize the remote `PRIMARY` selection by default: see [selections](#selections) below
* on MS Windows, the OS requests the clipboard data as soon as we claim ownership
* on MacOS, we have to use polling to see client-side changes
* 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, it may also request permission once and this cannot be easily enabled afterwards once it has been denied
* Wayland severely restricts access to the clipboard, making it impossible to synchronize it properly
Configuration Options
* `clipboard`: `auto`, `yes`, `no`, `all`, or the name of a clipboard implementation
* `clipboard-direction`: can be used to restrict the direction of the clipboard data transfers. This setting is also available from the system tray menu.
* `clipboard-filter-file`: can be used to filter out clipboard contents using a file containing regular expressions
* `local-clipboard` / `remote-clipboard`: can be used to select which clipboard selection to synchronize with
Selections
The default auto setting synchronizes all the selections
supported by the platform. On MS Windows and MacOS, auto is
equivalent to all.
--clipboard=all enables every selection that the
platform can handle. On Mac OSX and MS Windows clients, this adds the
PRIMARY selection, which is handled as a special case since
it does not exist locally:
- it is only ever synchronized from the server to the client, we never
claim it
- the server just notifies us when its contents change, and we then
request the data using a slow timer (200ms, configurable with the
XPRA_CLIPBOARD_PRIMARY_DELAY environment variable) so that
selecting text with the mouse does not flood the connection
- the data we receive is saved to the local
CLIPBOARD
selection, without claiming the remote CLIPBOARD
- a
CLIPBOARD token or a local clipboard change cancels
any pending PRIMARY request, so that a real copy always
wins over a mouse selection: if the request had already been sent, its
reply is discarded instead
This is implemented by PrimaryProxyMixin in xpra/clipboard/primary.py,
which both platform backends share.
Technical Constraints
Clipboard support is an ongoing struggle.
You must ensure that there are no other clipboard synchronization
tools already running as those are very likely to interfere and cause
synchronization loops, wasted bandwidth, trigger application bugs,
etc
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.
Debugging
Tool
There is a debugging tool which can be launched using
xpra clipboard-test.
The easiest way to test the clipboard on X11 platforms is to use
xclip tool to set and verify the contents of each
clipboard.
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.
Logging
just add -d clipboard to your xpra command line.
Useful Pointers
For low level implementation details, see [clipboard subsystem](../Subsystems/Clipboard.md).
- How
does X11 clipboard handle multiple data formats?
- x11-clipboard.cpp
from
VirtualBox
- operating
system specific clipboards on wikipedia
- The
X11 clipboard An overview of its problems and a proposed
solution 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).
Related tickets
- #2312
clipboard images with html5 client
- #2634
disable clipboard watermarks
- #1844
async clipboard api
- #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)