dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

dwm-6.1-cfacts.diff (3171B)


      1 diff --git a/config.def.h b/config.def.h
      2 index 875885b..809788b 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -65,6 +65,9 @@ static Key keys[] = {
      6  	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
      7  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
      8  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
      9 +	{ MODKEY|ShiftMask,             XK_h,      setcfact,       {.f = +0.25} },
     10 +	{ MODKEY|ShiftMask,             XK_l,      setcfact,       {.f = -0.25} },
     11 +	{ MODKEY|ShiftMask,             XK_o,      setcfact,       {.f =  0.00} },
     12  	{ MODKEY,                       XK_Return, zoom,           {0} },
     13  	{ MODKEY,                       XK_Tab,    view,           {0} },
     14  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     15 diff --git a/dwm.c b/dwm.c
     16 index 1bbb4b3..4ff74cc 100644
     17 --- a/dwm.c
     18 +++ b/dwm.c
     19 @@ -86,6 +86,7 @@ typedef struct Client Client;
     20  struct Client {
     21  	char name[256];
     22  	float mina, maxa;
     23 +	float cfact;
     24  	int x, y, w, h;
     25  	int oldx, oldy, oldw, oldh;
     26  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     27 @@ -200,6 +201,7 @@ static void setclientstate(Client *c, long state);
     28  static void setfocus(Client *c);
     29  static void setfullscreen(Client *c, int fullscreen);
     30  static void setlayout(const Arg *arg);
     31 +static void setcfact(const Arg *arg);
     32  static void setmfact(const Arg *arg);
     33  static void setup(void);
     34  static void showhide(Client *c);
     35 @@ -1027,6 +1029,7 @@ manage(Window w, XWindowAttributes *wa) {
     36  	c->w = c->oldw = wa->width;
     37  	c->h = c->oldh = wa->height;
     38  	c->oldbw = wa->border_width;
     39 +	c->cfact = 1.0;
     40  
     41  	if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
     42  		c->x = c->mon->mx + c->mon->mw - WIDTH(c);
     43 @@ -1473,6 +1476,23 @@ setlayout(const Arg *arg) {
     44  		drawbar(selmon);
     45  }
     46  
     47 +void setcfact(const Arg *arg) {
     48 +	float f;
     49 +	Client *c;
     50 +
     51 +	c = selmon->sel;
     52 +
     53 +	if(!arg || !c || !selmon->lt[selmon->sellt]->arrange)
     54 +		return;
     55 +	f = arg->f + c->cfact;
     56 +	if(arg->f == 0.0)
     57 +		f = 1.0;
     58 +	else if(f < 0.25 || f > 4.0)
     59 +		return;
     60 +	c->cfact = f;
     61 +	arrange(selmon);
     62 +}
     63 +
     64  /* arg > 1.0 will set mfact absolutly */
     65  void
     66  setmfact(const Arg *arg)
     67 @@ -1602,9 +1622,15 @@ tagmon(const Arg *arg) {
     68  tile(Monitor *m)
     69  {
     70  	unsigned int i, n, h, mw, my, ty;
     71 +	float mfacts = 0, sfacts = 0;
     72  	Client *c;
     73  
     74 -	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     75 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) {
     76 +		if (n < m->nmaster)
     77 +			mfacts += c->cfact;
     78 +		else
     79 +			sfacts += c->cfact;
     80 +	}
     81  	if (n == 0)
     82  		return;
     83  
     84 @@ -1614,14 +1640,16 @@ tile(Monitor *m) {
     85  		mw = m->ww;
     86  	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     87  		if (i < m->nmaster) {
     88 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     89 +			h = (m->wh - my) * (c->cfact / mfacts);
     90  			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     91  			my += HEIGHT(c);
     92 +			mfacts -= c->cfact;
     93  		}
     94  		else {
     95 -			h = (m->wh - ty) / (n - i);
     96 +			h = (m->wh - ty) * (c->cfact / sfacts);
     97  			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     98  			ty += HEIGHT(c);
     99 +			sfacts -= c->cfact;
    100  		}
    101  }
    102