ICCCM defined three selections 1)primary 2)secondary 3)clipboard. But in the xlib, xatom.h had defined only XA_PRIMARY and XA_SECONDARY but clipboard has no such atom. So my doubt is whether clipboard is implemented by xlib or has to be implemented by individual applications like primary and secondary ?
If it has to be implemented by individual applications, how different applications would interact with clipboard as in copy from one application's window and paste to another application's window..? How a common buffer is shared by different applications ? Can anybody help with the actual implementation of clipboard in linux..? I had gone through this link . But I dint find much information about the implementation.
bash $ xlsatoms | fgrep CLIPBOARD
231 CLIPBOARD
bash $ fgrep -r XA_CLIPBOARD /usr/include/X11
/usr/include/X11/Xmu/Atoms.h: _XA_CLIPBOARD,
/usr/include/X11/Xmu/Atoms.h:#define XA_CLIPBOARD(d) XmuInternAtom(d, _XA_CLIPBOARD)
So we have an atom, no problem with that. You can also just intern it by name.
The CLIPBOARD selection is implemented in exactly the same way as the other selections. The only difference is the moment when selection ownership is asserted. For PRIMARY, it's asserted when the user selects something; for CLIPBOARD, it's when the user cuts or copies.
The clipboard has to be implemented inside the X11 server (with a lot of supporting code inside the toolkits), simply because it is data shared by all the X11 clients.
It is defined by ICCCM and EWMH conventions and related to the desktop environment. It may use some non-predefined but conventionally named X11 atoms (there are many such conventional atoms not predefined in xatom.h
).
You'll better use some existing toolkit like Qt or Gtk (or FOX or FLTK). They are free software, and you could look inside if you really want to. For Qt, look into QClipboard, for GTK, look into GtkClipboard. So you don't really care about which atoms and X11 protocol is used to implement them.
freedesktop.org has a lot of resources, e.g. this, or the wm-spec etc etc etc...
See also wikipages on X Windows selection, X Windows System protocol and architecture, XDND and read the X11 protocol specifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With