Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  • Primary
  • Secondary
  • Clipboard
  • Cut buffers

What is the difference between these?

Experimenting with xclip and gedit:

Setting primary

Nothing happens, as far as I can tell

Setting secondary

Again, as far as I can tell, does not affect gedit

Setting clipboard

paste in edit and context menu is disabled, but pressing control-v causes the text I want to paste.

Copying in gedit

Appears to be setting primary and clipboard

What is each used for? How are they usually accessed in programs? How is it implemented? Are they properties on the root window (if so, what are their names)?

Cut buffers

I understand clip buffers are used in xterm when you select text, and are pasted when you middle click. Do any other programs use cut buffers?

share|improve this question
up vote 7 down vote accepted

X Selections, Cut Buffers, and Kill Rings

Clipboard: for when the user has explicitly copied something (e.g., the ``Edit/Copy'' menu item.)
Primary: more ephemeral and implicit: it is for when the user has highlighted or selected something (e.g., dragging the mouse over some text.)
Cut Buffers: Obsolete. Never, ever, ever use them. Ever.

Secondary? Defined in ICCCCCCCM, but I haven't found a single program that uses it.

Wikipedia's article on X Window selection says that only cut buffers were window properties of the root window, named CUT_BUFFER1 and so on.

share|improve this answer

X calls them "selections" rather than "clipboards". From Wikipedia (the whole article will probably help you, too):

At the level of the core protocol, the PRIMARY and CLIPBOARD selections do not differ. But the xclipboard client makes them behave differently. In particular, when another client asserts the ownership of the CLIPBOARD selection, this program requests and displays it in a window. Any further request for this selection are handled by xclipboard. This way, the content of the selection survives the client having copied it.

There is no inherent difference between them, the only difference is in the behavior of applications using them. For example, you could write a program that, when you pressed ctrl v, used the primary selection instead of clipboard, and it would be perfectly fine from a technical standpoint. The difference is social, in that users expect certain behavior, and it's smart to follow that the vast majority of the time.

I thought selecting text and middle-clicking to paste it was using the primary selection, rather than cut buffers (which are deprecated), but I could be wrong, as I've never coded directly against the X protocol.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .