sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

tcl.c (1274B)


      1 void
      2 tcl(Monitor * m)
      3 {
      4 	int x, y, h, w, mw, sw, bdw;
      5 	unsigned int i, n;
      6 	Client * c;
      7 
      8 	for (n = 0, c = nexttiled(m->clients); c;
      9 	        c = nexttiled(c->next), n++);
     10 
     11 	if (n == 0)
     12 		return;
     13 
     14 	c = nexttiled(m->clients);
     15 
     16 	mw = m->mfact * m->ww;
     17 	sw = (m->ww - mw) / 2;
     18 	bdw = (2 * c->bw);
     19 	resize(c,
     20 	       n < 3 ? m->wx : m->wx + sw,
     21 	       m->wy,
     22 	       n == 1 ? m->ww - bdw : mw - bdw,
     23 	       m->wh - bdw,
     24 	       False);
     25 
     26 	if (--n == 0)
     27 		return;
     28 
     29 	w = (m->ww - mw) / ((n > 1) + 1);
     30 	c = nexttiled(c->next);
     31 
     32 	if (n > 1)
     33 	{
     34 		x = m->wx + ((n > 1) ? mw + sw : mw);
     35 		y = m->wy;
     36 		h = m->wh / (n / 2);
     37 
     38 		if (h < bh)
     39 			h = m->wh;
     40 
     41 		for (i = 0; c && i < n / 2; c = nexttiled(c->next), i++)
     42 		{
     43 			resize(c,
     44 			       x,
     45 			       y,
     46 			       w - bdw,
     47 			       (i + 1 == n / 2) ? m->wy + m->wh - y - bdw : h - bdw,
     48 			       False);
     49 
     50 			if (h != m->wh)
     51 				y = c->y + HEIGHT(c);
     52 		}
     53 	}
     54 
     55 	x = (n + 1 / 2) == 1 ? mw : m->wx;
     56 	y = m->wy;
     57 	h = m->wh / ((n + 1) / 2);
     58 
     59 	if (h < bh)
     60 		h = m->wh;
     61 
     62 	for (i = 0; c; c = nexttiled(c->next), i++)
     63 	{
     64 		resize(c,
     65 		       x,
     66 		       y,
     67 		       (i + 1 == (n + 1) / 2) ? w - bdw : w - bdw,
     68 		       (i + 1 == (n + 1) / 2) ? m->wy + m->wh - y - bdw : h - bdw,
     69 		       False);
     70 
     71 		if (h != m->wh)
     72 			y = c->y + HEIGHT(c);
     73 	}
     74 }