On 2024-05-15, Michael <confabul...@kintzios.com> wrote: > As far as I know the Primary selection is not stored anywhere - > other than within the application's memory space where the range of > characters have been selected. The xserver will call for this when > you middle click to paste it on another application's window.
Right. When you highlight some text, the application asserts ownership of the primary selection, but no contents of the selection are transferred to the X server. So, the X server knows who owns the selection, but it doesn't actually store the contents anywhere. If you middle-click on a window, the X server will make a call to the owner of selection to get the selection contents and then provide that contents to the active window. When process (X client) that owns the selection exits, the selection becomes "empty" (unavailable). > The Clipboard may be stored in RAM or cache of any applications > which use this method. AFAICT, the clipboard contents is stored in the X server. When you cut/copy something, the application sends that something to the X server where it's stored. When that application exits, the clipboard contents are still there in the X server, and can still be requested by other applications who want to do a "paste". With the usual behavior, the selection and clipboard sort of overlap: When you highlight something the application asserts ownership of the primary selection, but nothing is transferred to the X server. If you then do a "copy", the application will send that highlighted text to the clipbard. If you haven't selected anything else, now you can either middle-click or paste, and you'll get the same thing. If you exit the app, then middle-click will produce nothing because there is no selection owner. But, paste will still get the "copied" data from the X server. That said, something doesn't have to be selected (in the X11 sense) to be copied into the clipboard -- but that's how most applications work first you select (in the X11 sense) something then you copy it to the clipboard. -- Grant