What is the X11 Secondary selection?

Recently I came across some text mentioning the X11 Secondary selection. I know X11 has Primary and Clipboard selections, and only those two are ever used in standard desktop apps. So what is this secondary selection?

(As an aside, the selection names are usually written in all-caps. I’ve opted not to do this, for readability purposes. Also, the primary selection is sometimes confusingly referred to as “primary clipboard”.)

There were a few red herrings that I found while searching the Web. The most straightforward explanation was from Vim’s documentation, saying that the secondary selection is “ill-defined”.

Then it occurred to me to read the X11 specification itself. Well, I couldn’t find the actual spec, but I found a 1990 paper on the design of X11. Check the Selections section (16th page on the PDF, labelled page 14 in the document), specifically the one on secondary selections (page 18 PDF, 16 document). Here’s a snippet:

‘A single global selection is insufficient in some user interface models, which may need the notion of the “current” selection yet also need to be able to communicate other information between applications, using the same request-reply model of the primary selection.

‘For example the user may want to swap the value of two items on the screen. He can make primary and secondary selections and then press a swap button.’

So there we go. The secondary selection is literally a secondary selection that you can use in addition to the primary selection. How you create and use the selection is application-dependent, but it’s a near-extinct feature that perhaps only exists in Emacs today.

2 thoughts on “What is the X11 Secondary selection?

    1. Johannes Sasongko Post author

      Hi Charles. Thanks for the interesting article, especially since it provides some of the context that I’m missing (I didn’t know that anything actively used the secondary selection). I might give your patched GTK+ a try one day, although unfortunately none of the text/code editors that I use are based on GtkTextView.


Note: By commenting, you grant me permission to freely republish your comment.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.