File: tile.c

package info (click to toggle)
dvtm 0.12-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 244 kB
  • ctags: 421
  • sloc: ansic: 3,925; makefile: 114; sh: 57
file content (50 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download
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
static void tile(void)
{
	unsigned int i, m, n, nx, ny, nw, nh, nm, mw, th;
	Client *c;

	for (n = 0, m = 0, c = clients; c; c = c->next, n++)
		if (c->minimized)
			m++;
	nm = n - m;
	/* window geoms */
	mw = (n == 1 || n - 1 == m) ? waw : screen.mfact * waw;
	/* check if there are at least 2 non minimized clients */
	if (n - 1 > m)
		th = (wah - m) / (nm - 1);

	nx = wax;
	ny = way;
	for (i = 0, c = clients; c; c = c->next, i++) {
		if (i == 0) {	/* master */
			nw = mw;
			nh = (n - 1 > m) ? wah : wah - m;
		} else {	/* tile window */
			if (!c->minimized) {
				if (i == 1) {
					ny = way;
					nx += mw;
					nw = waw - mw;
					mvvline(ny, nx, ACS_VLINE, wah);
					mvaddch(ny, nx, ACS_TTEE);
					nx++, nw--;
				}
				/* remainder */
				if (m == 0 && i + 1 == n)	/* no minimized clients */
					nh = (way + wah) - ny;
				else if (i == nm - 1)	/* last not minimized client */
					nh = (way + wah - (n - i - 1)) - ny;
				else
					nh = th;
			} else {
				nh = 1;
				ny = way + wah - (n - i);
			}
			if (i > 1 && nm > 1)
				mvaddch(ny, nx - 1, ACS_LTEE);
		}
		resize(c, nx, ny, nw, nh);
		if (n > 1 && th != wah)
			ny += nh;
	}
}