File: bstack.c

package info (click to toggle)
dvtm 0.4.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 160 kB
  • ctags: 361
  • sloc: ansic: 2,116; makefile: 99; sh: 12
file content (57 lines) | stat: -rw-r--r-- 1,122 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
51
52
53
54
55
56
57
void
bstack(void) {
	unsigned int i, m, n, nx, ny, nw, nh, mh, tw;
	Client *c;

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

	if(n == 1)
		mh = wah;
	else if(n - 1 == m)
		mh = wah - m;
	else
		mh = mwfact * (wah - m);
	/* true if there are at least 2 non minimized clients */
	if(n - 1 > m)
		tw = waw / (n - m - 1);

	nx = wax;
	ny = way;
	for(i = 0, c = clients; c; c = c->next, i++){
		if(i == 0){ /* master */
			nh = mh;
			nw = waw;
		} else { /* tile window */
			if(i == 1){
				nx = wax;
				ny += mh;
				nh = (way + wah - m) - ny;
			}
			if(i == n - m - 1){ /* last not minimized client */
				nw = (wax + waw) - nx;
			} else if(i == n - m){ /* first minimized client */
				ny += nh;
				nx = wax;
				nw = waw;
				nh = 1;
			} else if(c->minimized) { /* minimized window */
				nw = waw;
				nh = 1;
				ny++;
			} else /* normal non minimized tile window */
				nw = tw;
			if(i > 1 && !c->minimized){
				mvvline(ny, nx, ACS_VLINE, nh);
				mvaddch(ny, nx, ACS_TTEE);
				nx++, nw--;
			}
		}

		resize(c,nx,ny,nw,nh);

		if(n > 1 && i < n - m - 1)
			nx += nw;
	}
}