aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/layout.c
blob: f7a2c6048cdc51af16e31a670eb9ec1b4bee1929 (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
#include "dwm.h"

void 
tile(Monitor *m)
{
	Client *c;
	uint i, n, h, mw, my, ty;

    n = 0;
	wl_list_for_each(c, &dwm.tiles, link.tiles)
		if (VISIBLEON(c, m) && !c->floating)
			n++;

	if (n == 0)
		return;

	if (n > m->nmaster)
		mw = m->nmaster ? m->area.win.width * m->mfact : 0;
	else
		mw = m->area.win.width;

	i = my = ty = 0;
	wl_list_for_each(c, &dwm.tiles, link.tiles) {
		if (!VISIBLEON(c, m) || c->floating)
			continue;
		if (i < m->nmaster) {
			h = (m->area.win.height - my) / (MIN(n, m->nmaster) - i);
			resize(c, m->area.win.x, m->area.win.y + my, mw, h, 0);
			my += c->dim.height;
		} else {
			h = (m->area.win.height - ty) / (n - i);
			resize(c, m->area.win.x + mw, m->area.win.y + ty, m->area.win.width - mw, h, 0);
			ty += c->dim.height;
		}
		i++;
	}
}