Clipboard

August 16, 2026 ยท View on GitHub

For usage related information, see clipboard feature.

The prefix for all packets and capabilities is clipboard.

ComponentLink
clientxpra.client.subsystem.clipboard
client connectionxpra.server.source.clipboard
serverxpra.server.subsystem.clipboard

xpra.clipboard contains the platform independent base class used by all the backends. It contains common features such as basic configuration, scheduling, filtering, etc.

PlatformLink
x11xpra.x11.gtk_x11.clipboard
win32xpra.platform.win32.clipboard
MacOSxpra.platform.darwin.clipboard
othersxpra.gtk_common.gtk_clipboard

The client and server should expose the following capabilities in their hello packet using the clipboard prefix:

CapabilityValueInformation
notificationsbooleanRequest clipboard-pending-requests packets
want_targetsboolean or list of stringsInclude targets for all or the named selections in clipboard-data
greedyboolean or list of stringsInclude contents for all or the named selections in clipboard-data
preferred-targetslist of stringsThe targets that the peer should prefer
selectionslist of stringsClipboard selections supported by this endpoint
directionstringOne of disabled, to-client, to-server or both

Notes:

  • an absent clipboard map means that the subsystem is unavailable;
  • MacOS clients normally request targets;
  • both MacOS and MS Windows clients normally use greedy synchronization.

Example capabilities

  • X11 Client:
{
  'clipboard': {
    'enabled': true,
    'notifications': true,
    'selections': ['CLIPBOARD', 'PRIMARY', 'SECONDARY'],
    'preferred-targets': ['UTF8_STRING', 'TEXT', 'STRING', 'text/plain', 'image/png'],
    'direction': "both",
  },
}
  • X11 seamless server:
{
  'clipboard': {
    'notifications': true,
    'selections': ['CLIPBOARD', 'PRIMARY', 'SECONDARY'],
    'preferred-targets': ['UTF8_STRING', 'TEXT', 'STRING', 'text/plain', 'image/png'],
    'direction': 'both',
  }
}

This protocol is identical in both directions, as either end can send and receive clipboard events.

Packet TypeArgumentsInformation
clipboard-statusenabled: boolean, reason: string optionalEnable or disable synchronization
clipboard-enable-selectionslist of selectionsSelect the clipboards to synchronize
clipboard-dataselection, options dictionaryAnnounce ownership and optionally include targets and contents
clipboard-requestrequest-id, selection, targetRequest clipboard contents
clipboard-contentsrequest-id, selection, data-type, data-format, wire-encoding, dataRespond to clipboard-request
clipboard-contents-nonerequest-id, selection optionalEmpty response to clipboard-request
clipboard-pending-requestspending-requests: integerNumber of requests waiting

The clipboard-data options are claim, greedy, token, synchronous, targets and data. data maps each target to a four-item value containing data-type, data-format, wire-encoding and the wire data.

Clipboard data format details:

ArgumentData typeInformation
selectionstringX11 supports 3 different clipboards, known as selections
request-idintegerEach clipboard-request should use a new unique identifier
targetstringA clipboard format, ie: STRING, UTF8_STRING, text/plain
data-typestringThe type of the contents, ie: bytes or ATOM
data-formatintegerThe number of bits used by each item
wire-encodingstringEncoding used to convert the platform value to the wire form
datavariableTypically bytes, atoms or encoded text

Flow

Whenever a clipboard change is detected, a clipboard-data packet must be sent to the peer. If the peer advertises want_targets, the targets option must be included. If the peer advertises greedy, matching contents must be included in the data option. The contents may also be included if it is desirable to avoid a roundtrip later.

If the targets or the contents of the clipboard selection are needed, a peer can send a clipboard-request with a unique request_id. (use the value TARGETS as the target to get list of targets)

When requesting the clipboard contents, the target value chosen should be one of the values from the list of targets. If not, the peer may try to convert one of the valid targets.

If a value is sucessfully retrieved, a clipboard-contents packet is sent back, otherwise a clipboard-contents-none is used.