dvtm

Fork of dvtm, a minimal terminal multiplexer
git clone git://git.laack.co/dvtm.git
Log | Files | Refs | README | LICENSE

tile.c (1036B)


      1 static void tile(void)
      2 {
      3 	unsigned int i, n, nx, ny, nw, nh, m, mw, mh, th;
      4 	Client *c;
      5 
      6 	for (n = 0, c = nextvisible(clients); c; c = nextvisible(c->next))
      7 		if (!c->minimized)
      8 			n++;
      9 
     10 	m  = MAX(1, MIN(n, screen.nmaster));
     11 	mw = n == m ? waw : screen.mfact * waw;
     12 	mh = wah / m;
     13 	th = n == m ? 0 : wah / (n - m);
     14 	nx = wax;
     15 	ny = way;
     16 
     17 	for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next)) {
     18 		if (c->minimized)
     19 			continue;
     20 		if (i < m) {	/* master */
     21 			nw = mw;
     22 			nh = (i < m - 1) ? mh : (way + wah) - ny;
     23 		} else {	/* tile window */
     24 			if (i == m) {
     25 				ny = way;
     26 				nx += mw;
     27 				mvvline(ny, nx, ACS_VLINE, wah);
     28 				mvaddch(ny, nx, ACS_TTEE);
     29 				nx++;
     30 				nw = waw - mw -1;
     31 			}
     32 			nh = (i < n - 1) ? th : (way + wah) - ny;
     33 			if (i > m)
     34 				mvaddch(ny, nx - 1, ACS_LTEE);
     35 		}
     36 		resize(c, nx, ny, nw, nh);
     37 		ny += nh;
     38 		i++;
     39 	}
     40 
     41 	/* Fill in nmaster intersections */
     42 	if (n > m) {
     43 		ny = way + mh;
     44 		for (i = 1; i < m; i++) {
     45 			mvaddch(ny, nx - 1, ((ny - 1) % th ? ACS_RTEE : ACS_PLUS));
     46 			ny += mh;
     47 		}
     48 	}
     49 }