sites

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

dwm-cfacts-6.2.diff (2999B)


      1 diff -uraN a/config.def.h b/config.def.h
      2 --- a/config.def.h	2019-02-02 15:55:28.000000000 +0300
      3 +++ b/config.def.h	2020-02-18 03:33:58.212113667 +0300
      4 @@ -70,6 +70,9 @@
      5  	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
      6  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
      7  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
      8 +	{ MODKEY|ShiftMask,             XK_h,      setcfact,       {.f = +0.25} },
      9 +	{ MODKEY|ShiftMask,             XK_l,      setcfact,       {.f = -0.25} },
     10 +	{ MODKEY|ShiftMask,             XK_o,      setcfact,       {.f =  0.00} },
     11  	{ MODKEY,                       XK_Return, zoom,           {0} },
     12  	{ MODKEY,                       XK_Tab,    view,           {0} },
     13  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     14 diff -uraN a/dwm.c b/dwm.c
     15 --- a/dwm.c	2019-02-02 15:55:28.000000000 +0300
     16 +++ b/dwm.c	2020-02-18 03:33:58.213447007 +0300
     17 @@ -87,6 +87,7 @@
     18  struct Client {
     19  	char name[256];
     20  	float mina, maxa;
     21 +	float cfact;
     22  	int x, y, w, h;
     23  	int oldx, oldy, oldw, oldh;
     24  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     25 @@ -200,6 +201,7 @@
     26  static void setfocus(Client *c);
     27  static void setfullscreen(Client *c, int fullscreen);
     28  static void setlayout(const Arg *arg);
     29 +static void setcfact(const Arg *arg);
     30  static void setmfact(const Arg *arg);
     31  static void setup(void);
     32  static void seturgent(Client *c, int urg);
     33 @@ -1029,6 +1031,7 @@
     34  	c->w = c->oldw = wa->width;
     35  	c->h = c->oldh = wa->height;
     36  	c->oldbw = wa->border_width;
     37 +	c->cfact = 1.0;
     38  
     39  	updatetitle(c);
     40  	if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) {
     41 @@ -1511,6 +1514,23 @@
     42  		drawbar(selmon);
     43  }
     44  
     45 +void setcfact(const Arg *arg) {
     46 +	float f;
     47 +	Client *c;
     48 +
     49 +	c = selmon->sel;
     50 +
     51 +	if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
     52 +		return;
     53 +	f = arg->f + c->cfact;
     54 +	if(arg->f == 0.0)
     55 +		f = 1.0;
     56 +	else if(f < 0.25 || f > 4.0)
     57 +		return;
     58 +	c->cfact = f;
     59 +	arrange(selmon);
     60 +}
     61 +
     62  /* arg > 1.0 will set mfact absolutely */
     63  void
     64  setmfact(const Arg *arg)
     65 @@ -1674,9 +1694,15 @@
     66  tile(Monitor *m)
     67  {
     68  	unsigned int i, n, h, mw, my, ty;
     69 +	float mfacts = 0, sfacts = 0;
     70  	Client *c;
     71  
     72 -	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     73 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
     74 +		if (n < m->nmaster)
     75 +			mfacts += c->cfact;
     76 +		else
     77 +			sfacts += c->cfact;
     78 +	}
     79  	if (n == 0)
     80  		return;
     81  
     82 @@ -1686,13 +1712,15 @@
     83  		mw = m->ww;
     84  	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     85  		if (i < m->nmaster) {
     86 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     87 +			h = (m->wh - my) * (c->cfact / mfacts);
     88  			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     89  			my += HEIGHT(c);
     90 +			mfacts -= c->cfact;
     91  		} else {
     92  			h = (m->wh - ty) / (n - i);
     93  			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     94  			ty += HEIGHT(c);
     95 +			sfacts -= c->cfact;
     96  		}
     97  }
     98