Linux – the difference between the X clipboards

linuxunixxorg

  • 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?

Best Answer

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.