polytreewm/src/atoms.c

48 lines
1.2 KiB
C
Raw Normal View History

2021-11-12 09:02:46 +00:00
#include "atoms.h"
2021-11-12 09:04:13 +00:00
#include <stdlib.h>
2021-12-04 16:12:45 +00: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 09:07:15 +00:00
Atoms atoms_create(Display *const dpy)
2021-11-12 09:04:13 +00:00
{
2021-11-12 09:07:15 +00:00
Atoms atoms = malloc(sizeof(struct Atoms));
2021-12-04 16:12:45 +00: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 09:07:15 +00:00
atoms->utf8string = XInternAtom(dpy, "UTF8_STRING", False);
2021-11-12 09:07:15 +00:00
return atoms;
2021-11-12 09:04:13 +00:00
}
2021-11-21 06:11:11 +00:00
void atoms_delete(Atoms atoms)
2021-11-12 09:02:46 +00:00
{
2021-11-21 06:11:11 +00:00
// TODO: maybe we should assert
if (atoms == NULL) return;
2021-11-12 09:07:15 +00:00
free(atoms);
2021-11-12 09:02:46 +00:00
}