2021-11-12 04:02:46 -05:00
|
|
|
#include "atoms.h"
|
|
|
|
|
2021-11-12 04:04:13 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2021-12-04 11:12:45 -05:00
|
|
|
static const char *const default_atoms[WMLast] = {
|
|
|
|
[WMProtocols] = "WM_PROTOCOLS",
|
|
|
|
[WMDelete] = "WM_DELETE_WINDOW",
|
|
|
|
[WMState] = "WM_STATE",
|
|
|
|
[WMTakeFocus] = "WM_TAKE_FOCUS",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *const ewmh_atoms[NetLast] = {
|
|
|
|
[NetActiveWindow] = "_NET_ACTIVE_WINDOW",
|
|
|
|
[NetSupported] = "_NET_SUPPORTED",
|
|
|
|
[NetWMName] = "_NET_WM_NAME",
|
|
|
|
[NetWMState] = "_NET_WM_STATE",
|
|
|
|
[NetWMCheck] = "_NET_SUPPORTING_WM_CHECK",
|
|
|
|
[NetWMFullscreen] = "_NET_WM_STATE_FULLSCREEN",
|
|
|
|
[NetWMWindowType] = "_NET_WM_WINDOW_TYPE",
|
|
|
|
[NetWMWindowTypeDialog] = "_NET_WM_WINDOW_TYPE_DIALOG",
|
|
|
|
[NetClientList] = "_NET_CLIENT_LIST",
|
|
|
|
};
|
|
|
|
|
2021-11-12 04:07:15 -05:00
|
|
|
Atoms atoms_create(Display *const dpy)
|
2021-11-12 04:04:13 -05:00
|
|
|
{
|
2021-11-12 04:07:15 -05:00
|
|
|
Atoms atoms = malloc(sizeof(struct Atoms));
|
|
|
|
|
2021-12-04 11:12:45 -05:00
|
|
|
for (int index = 0; index < WMLast; ++index) {
|
|
|
|
atoms->wmatom[index] = XInternAtom(dpy, default_atoms[index], False);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int index = 0; index < NetLast; ++index) {
|
|
|
|
atoms->netatom[index] = XInternAtom(dpy, ewmh_atoms[index], False);
|
|
|
|
}
|
2021-11-12 04:07:15 -05:00
|
|
|
|
2021-11-12 17:36:10 -05:00
|
|
|
atoms->utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
|
|
|
|
2021-11-12 04:07:15 -05:00
|
|
|
return atoms;
|
2021-11-12 04:04:13 -05:00
|
|
|
}
|
|
|
|
|
2021-11-21 01:11:11 -05:00
|
|
|
void atoms_delete(Atoms atoms)
|
2021-11-12 04:02:46 -05:00
|
|
|
{
|
2021-11-21 01:11:11 -05:00
|
|
|
// TODO: maybe we should assert
|
|
|
|
if (atoms == NULL) return;
|
|
|
|
|
2021-11-12 04:07:15 -05:00
|
|
|
free(atoms);
|
2021-11-12 04:02:46 -05:00
|
|
|
}
|