~kaction/dvtm

dvtm/vstack.c -rw-r--r-- 684 bytes
51d01e91 — Dmitry Bogatov Release 0.15.2 3 months ago
                                                                                
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
/* A vertical stack layout, all windows have the full screen width. */
static void vstack(void)
{
	unsigned int i, n, ny, nh, m, mh, th;
	Client *c;

	for (n = 0, c = nextvisible(clients); c; c = nextvisible(c->next))
		if (!c->minimized)
			n++;

	m  = MAX(1, MIN(n, screen.nmaster));
	mh = (n == m ? wah : screen.mfact * wah);
	th = n == m ? 0 : (wah - mh) / (n - m);
	ny = way;

	for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next)) {
		if (c->minimized)
			continue;
		if (i < m) /* master */
			nh = (i < m - 1) ? mh / m : (way + mh) - ny;
		else /* tile window */
			nh = (i < n - 1) ? th : (way + wah) - ny;
		resize(c, wax, ny, waw, nh);
		ny += nh;
		i++;
	}
}