summaryrefslogtreecommitdiffhomepage
path: root/patch/bar_anybar.c
blob: cc4b714502f6741489325d744a256ac08bab3b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
void
managealtbar(Window win, XWindowAttributes *wa)
{
	Monitor *m;
	if (!(m = recttomon(wa->x, wa->y, wa->width, wa->height)))
		return;

	m->bar->win = win;
	m->bar->by = wa->y;
	bh = m->bar->bh = wa->height;
	updatebarpos(m);
	arrange(m);
	XSelectInput(dpy, win, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
	XMoveResizeWindow(dpy, win, wa->x, wa->y, wa->width, wa->height);
	XMapWindow(dpy, win);
	XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
		(unsigned char *) &win, 1);
}

void
spawnbar()
{
	if (*altbarcmd)
		system(altbarcmd);
}

void
unmanagealtbar(Window w)
{
    Monitor *m = wintomon(w);

    if (!m)
        return;

    m->bar->win = 0;
    m->bar->by = 0;
    m->bar->bh = 0;
    updatebarpos(m);
    arrange(m);
}

int
wmclasscontains(Window win, const char *class, const char *name)
{
	XClassHint ch = { NULL, NULL };
	int res = 1;

	if (XGetClassHint(dpy, win, &ch)) {
		if (ch.res_name && strstr(ch.res_name, name) == NULL)
			res = 0;
		if (ch.res_class && strstr(ch.res_class, class) == NULL)
			res = 0;
	} else
		res = 0;

	if (ch.res_class)
		XFree(ch.res_class);
	if (ch.res_name)
		XFree(ch.res_name);

	return res;
}