Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is clipboard implemented by xlib or to be implemented by individual applications

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.

like image 218
santosh kumar Avatar asked Mar 22 '23 19:03

santosh kumar


2 Answers

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.

like image 137
n. 1.8e9-where's-my-share m. Avatar answered Apr 05 '23 22:04

n. 1.8e9-where's-my-share m.


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.

like image 34
Basile Starynkevitch Avatar answered Apr 05 '23 23:04

Basile Starynkevitch