implement a table of atoms defined only once

Previously, adding a new atom into the code required:
1. In <icc.h>, add the line `extern Atom my_new_atom;` declaring the new atom.
2. In <icc.c>, add the line `Atom my_new_atom;` defining the new atom.
3. In <icc.c>, add the line `my_new_atom = XInternAtom(dpy, "MY_NEW_ATOM", False);`
   interning this new atom, and assigning the interned value to the variable.

Now, just add a line with the atom's name in the X-MACRO in <icc.h>, and
a XInternAtoms(3) and a set of macros will do the rest.

All new atoms will be referred to as an entry in the ATOMS[] array.
For example:

	ATOMS[MY_NEW_ATOM]

The exception are for those REALLY OLD atoms that have already a
dedicated compile-time-known value defined at <X11/Xatom.h>.  Those
do not need to be interned; and are referred to with a constant
beginning with the `XA_` prefix.  For example:

	XA_WM_CLASS
This commit is contained in:
Lucas de Sena
2026-02-19 20:22:50 +00:00
parent f3fc2a7015
commit ca04f20fec
6 changed files with 84 additions and 77 deletions

View File

@@ -61,9 +61,9 @@ void setvirtualroot(Scrn *s)
if(s==old_vroot) return;
if(old_vroot)
XDeleteProperty(dpy, old_vroot->back, swm_vroot);
XDeleteProperty(dpy, old_vroot->back, ATOMS[__SWM_VROOT]);
setvroot(s->root, s);
XChangeProperty(dpy, s->back, swm_vroot, XA_WINDOW, 32, PropModeReplace,
XChangeProperty(dpy, s->back, ATOMS[__SWM_VROOT], XA_WINDOW, 32, PropModeReplace,
(unsigned char *)&(s->back), 1);
}
}