dwm

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

layout_centeredfloatingmaster.c (2493B)


      1 void
      2 centeredfloatingmaster(Monitor *m)
      3 {
      4 	unsigned int i, n;
      5 	float mfacts, sfacts;
      6 	int mrest, srest;
      7 	int mx = 0, my = 0, mh = 0, mw = 0;
      8 	int sx = 0, sy = 0, sh = 0, sw = 0;
      9 	Client *c;
     10 
     11 	#if VANITYGAPS_PATCH
     12 	float mivf = 1.0; // master inner vertical gap factor
     13 	int oh, ov, ih, iv;
     14 	getgaps(m, &oh, &ov, &ih, &iv, &n);
     15 	#else
     16 	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     17 	#endif // VANITYGAPS_PATCH
     18 
     19 	if (n == 0)
     20 		return;
     21 
     22 	#if VANITYGAPS_PATCH
     23 	sx = mx = m->wx + ov;
     24 	sy = my = m->wy + oh;
     25 	sh = mh = m->wh - 2*oh;
     26 	mw = m->ww - 2*ov - iv*(n - 1);
     27 	sw = m->ww - 2*ov - iv*(n - m->nmaster - 1);
     28 
     29 	if (m->nmaster && n > m->nmaster) {
     30 		mivf = 0.8;
     31 		/* go mfact box in the center if more than nmaster clients */
     32 		if (m->ww > m->wh) {
     33 			mw = m->ww * m->mfact - iv*mivf*(MIN(n, m->nmaster) - 1);
     34 			mh = m->wh * 0.9;
     35 		} else {
     36 			mw = m->ww * 0.9 - iv*mivf*(MIN(n, m->nmaster) - 1);
     37 			mh = m->wh * m->mfact;
     38 		}
     39 		mx = m->wx + (m->ww - mw) / 2;
     40 		my = m->wy + (m->wh - mh - 2*oh) / 2;
     41 
     42 		sx = m->wx + ov;
     43 		sy = m->wy + oh;
     44 		sh = m->wh - 2*oh;
     45 	}
     46 	#else
     47 	sx = mx = m->wx;
     48 	sy = my = m->wy;
     49 	sh = mh = m->wh;
     50 	sw = mw = m->ww;
     51 
     52 	if (m->nmaster && n > m->nmaster) {
     53 		/* go mfact box in the center if more than nmaster clients */
     54 		if (m->ww > m->wh) {
     55 			mw = m->ww * m->mfact;
     56 			mh = m->wh * 0.9;
     57 		} else {
     58 			mw = m->ww * 0.9;
     59 			mh = m->wh * m->mfact;
     60 		}
     61 		mx = m->wx + (m->ww - mw) / 2;
     62 		my = m->wy + (m->wh - mh) / 2;
     63 	}
     64 	#endif // VANITYGAPS_PATCH
     65 
     66 	getfacts(m, mw, sw, &mfacts, &sfacts, &mrest, &srest);
     67 
     68 	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     69 		if (i < m->nmaster) {
     70 			/* nmaster clients are stacked horizontally, in the center of the screen */
     71 			#if CFACTS_PATCH
     72 			resize(c, mx, my, (mw / mfacts) * c->cfact + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
     73 			#else
     74 			resize(c, mx, my, (mw / mfacts) + (i < mrest ? 1 : 0) - (2*c->bw), mh - (2*c->bw), 0);
     75 			#endif // CFACTS_PATCH
     76 			#if VANITYGAPS_PATCH
     77 			mx += WIDTH(c) + iv*mivf;
     78 			#else
     79 			mx += WIDTH(c);
     80 			#endif
     81 		} else {
     82 			/* stack clients are stacked horizontally */
     83 			#if CFACTS_PATCH
     84 			resize(c, sx, sy, (sw / sfacts) * c->cfact + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
     85 			#else
     86 			resize(c, sx, sy, (sw / sfacts) + ((i - m->nmaster) < srest ? 1 : 0) - (2*c->bw), sh - (2*c->bw), 0);
     87 			#endif // CFACTS_PATCH
     88 			#if VANITYGAPS_PATCH
     89 			sx += WIDTH(c) + iv;
     90 			#else
     91 			sx += WIDTH(c);
     92 			#endif
     93 		}
     94 }
     95