dwm

Kris's build of dwm
git clone git clone https://git.krisyotam.com/krisyotam/dwm.git
Log | Files | Refs | README | LICENSE

layout_horizgrid.c (2390B)


      1 void
      2 horizgrid(Monitor *m) {
      3 	Client *c;
      4 	unsigned int n, i;
      5 	int mx = 0, my = 0, mh = 0, mw = 0;
      6 	int sx = 0, sy = 0, sh = 0, sw = 0;
      7 	int ntop;
      8 	float mfacts = 0, sfacts = 0;
      9 	int mrest, srest, mtotal = 0, stotal = 0;
     10 
     11 	#if VANITYGAPS_PATCH
     12 	int oh, ov, ih, iv;
     13 	getgaps(m, &oh, &ov, &ih, &iv, &n);
     14 	#else
     15 	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     16 	#endif // VANITYGAPS_PATCH
     17 	if (n == 0)
     18 		return;
     19 
     20 	if (n <= 2)
     21 		ntop = n;
     22 	else {
     23 		ntop = n / 2;
     24 	}
     25 
     26 	#if VANITYGAPS_PATCH
     27 	sx = mx = m->wx + ov;
     28 	sy = my = m->wy + oh;
     29 	sh = mh = m->wh - 2*oh;
     30 	sw = mw = m->ww - 2*ov;
     31 
     32 	if (n > ntop) {
     33 		sh = (mh - ih) / 2;
     34 		mh = mh - ih - sh;
     35 		sy = my + mh + ih;
     36 		mw = m->ww - 2*ov - iv * (ntop - 1);
     37 		sw = m->ww - 2*ov - iv * (n - ntop - 1);
     38 	}
     39 	#else
     40 	sx = mx = m->wx;
     41 	sy = my = m->wy;
     42 	sh = mh = m->wh;
     43 	sw = mw = m->ww;
     44 
     45 	if (n > ntop) {
     46 		sh = mh / 2;
     47 		mh = mh - sh;
     48 		sy = my + mh;
     49 	}
     50 	#endif // VANITYGAPS_PATCH
     51 
     52 	/* calculate facts */
     53 	#if CFACTS_PATCH
     54 	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     55 		if (i < ntop)
     56 			mfacts += c->cfact;
     57 		else
     58 			sfacts += c->cfact;
     59 
     60 	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     61 		if (i < ntop)
     62 			mtotal += mh * (c->cfact / mfacts);
     63 		else
     64 			stotal += sw * (c->cfact / sfacts);
     65 	#else
     66 	mfacts = ntop;
     67 	sfacts = n - ntop;
     68 
     69 	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     70 		if (i < ntop)
     71 			mtotal += mh / mfacts;
     72 		else
     73 			stotal += sw / sfacts;
     74 	#endif // CFACTS_PATCH
     75 
     76 	mrest = mh - mtotal;
     77 	srest = sw - stotal;
     78 
     79 	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     80 		if (i < ntop) {
     81 			#if CFACTS_PATCH
     82 			resize(c, mx, my, mw * (c->cfact / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
     83 			#else
     84 			resize(c, mx, my, mw / mfacts + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
     85 			#endif // CFACTS_PATCH
     86 			#if VANITYGAPS_PATCH
     87 			mx += WIDTH(c) + iv;
     88 			#else
     89 			mx += WIDTH(c);
     90 			#endif // VANITYGAPS_PATCH
     91 		} else {
     92 			#if CFACTS_PATCH
     93 			resize(c, sx, sy, sw * (c->cfact / sfacts) + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
     94 			#else
     95 			resize(c, sx, sy, sw / sfacts + ((i - ntop) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
     96 			#endif // CFACTS_PATCH
     97 			#if VANITYGAPS_PATCH
     98 			sx += WIDTH(c) + iv;
     99 			#else
    100 			sx += WIDTH(c);
    101 			#endif // VANITYGAPS_PATCH
    102 		}
    103 }
    104