This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Primary Selection

X has a generic selection mechanism which lets application own arbitrary selections and exchange data via them. This is used both for DND as well as for clipboards. Historically, there has been some confusion about the intended semantics of multiple clipboards in X, but http://www.freedesktop.org/wiki/Specifications/clipboards-extension-spec/ has emerged as a more or less universal consensus as to how things should work under X:

The original Wayland protocol very intentionally supports only a single clipboard, which corresponds to the CLIPBOARD selection under X and works for explicit copy-paste. Among the arguments for eschewing the PRIMARY selection were:

Additionally, reasons against keeping it:

Still, many longterm X users have become reliant on this easter egg, and in particular terminal users have a hard time using the awkward Shift-Ctrl-C combination instead (since Ctrl-C is not available in terminals).

Therefore, we should consider bringing back primary selections in some form under Wayland, to ease the transition for long-term X users.

Constraints for a Wayland primary selection

We should address the security concerns by making sure that

We should make sure that the feature is reliable

Comments

11/9/2015 from Lyude: So one thing I'm not too keen on here is using an input event like a middle button click in order to request the contents of the front buffer on the protocol level. If we make a protocol for a PRIMARY buffer manager, we should be able to just send a wl_data_offer to the client during a scenario where we would want to allow it to paste from the primary buffer if it chooses to do so, e.g. when the user clicks the middle button. I'm going to try to come up with a rough draft of a protocol for this, I'll update this once I've got something.

Update: Here's that something: primary_selection_manager.txt One of the things that's been brought up about this is the fact I've chosen not to use the serials coming from the middle mouse button with this. My reasoning for doing so is what I stated above along with the fact that apparently it's quite common for users to remap this to a different key, so we don't really want to force the protocol to rely on any specific keybinding or mouse event. I'm willing to change this of course if others think using the serial from the middle mouse button would be a better idea.

Discussion

(Summary of a hallway discussion between Owen, Lyude and Matthias)

Protocol walkthrough:

We discussed binding the primary paste to a keyboard shortcut, but decided that it would be easier if the compositor had an out-of-band API for defining a keyboard shortcut that synthesizes a middle-click. If a keyboard shortcut is bound that way (from the keyboard panel in the control-center), the compositor will detect this key event and synthesize a middle-click (and do the other actions outlined above for actual middle-click events).

Note that while the walkthrough talks about selecting text, the protocol should be general to allow any content type for the primary selection.


2024-10-23 11:17