I know this is an old thread, but I just had to add a bit of explanation to this:
XWindows has a PRIMARY selection and a CLIPBOARD selection.
PRIMARY is the text that is “selected” on the screen. Only one application can own the PRIMARY selection at any given time. If you select in another window, the selection in the first window disappears. Once you’ve selected text, it goes into the PRIMARY selection. If you click somewhere and release the selection, the contents of PRIMARY are still available to middle-click as long as nothing else has been selected, as that would replace the contents of PRIMARY again.
If you press Ctrl-C, the currently selected text is copied to CLIPBOARD. (It also ends up in PRIMARY, because you had to select something to copy.)
When you middle-click, X is taking PRIMARY and pasting it wherever you middle click. This does not affect the CLIPBOARD.
If the PRIMARY selection is empty when you middle-click, X will paste the contents of the CLIPBOARD.
When you press Ctrl-V, X will paste the CLIPBOARD selection to where your cursor is.
You can select something, copy it, select something else, then alternate between Ctrl-V and middle-click to see that your CLIPBOARD is unmodified.
I’ve also left out the parts relating to things other than text in a CLIPBOARD. (Images, files, etc)
(Also, when I say XWindows and X above, I probably mean the X client (the application), not the X server, as it’s probably the X client that is implementing the copy/paste logic. This means that everything above could be different for non-compliant applications. There is also a SECONDARY selection, but I haven’t seen where this is used. The selections are in CAPS because this is how it is defined in the X11 Protocol.)