sites

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

dwm-savefloats-20160723-56a31dc.diff (1452B)


      1 diff --git a/dwm.c b/dwm.c
      2 index cfea881..87a23c4 100644
      3 --- a/dwm.c
      4 +++ b/dwm.c
      5 @@ -107,6 +107,7 @@ struct Client {
      6  	char name[256];
      7  	float mina, maxa;
      8  	int x, y, w, h;
      9 +	int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
     10  	int oldx, oldy, oldw, oldh;
     11  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     12  	int bw, oldbw;
     13 @@ -1205,10 +1206,10 @@ manage(Window w, XWindowAttributes *wa)
     14  	c = ecalloc(1, sizeof(Client));
     15  	c->win = w;
     16  	/* geometry */
     17 -	c->x = c->oldx = wa->x;
     18 -	c->y = c->oldy = wa->y;
     19 -	c->w = c->oldw = wa->width;
     20 -	c->h = c->oldh = wa->height;
     21 +	c->sfx = c->x = c->oldx = wa->x;
     22 +	c->sfy = c->y = c->oldy = wa->y;
     23 +	c->sfw = c->w = c->oldw = wa->width;
     24 +	c->sfh = c->h = c->oldh = wa->height;
     25  	c->oldbw = wa->border_width;
     26  
     27  	updatetitle(c);
     28 @@ -1976,8 +1977,16 @@ togglefloating(const Arg *arg)
     29  		return;
     30  	selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
     31  	if (selmon->sel->isfloating)
     32 -		resize(selmon->sel, selmon->sel->x, selmon->sel->y,
     33 -		       selmon->sel->w, selmon->sel->h, 0);
     34 +		/* restore last know float dimentions */
     35 +		resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
     36 +		       selmon->sel->sfw, selmon->sel->sfh, 0);
     37 +	else {
     38 +		/* save last known float dimentions */
     39 +		selmon->sel->sfx = selmon->sel->x;
     40 +		selmon->sel->sfy = selmon->sel->y;
     41 +		selmon->sel->sfw = selmon->sel->w;
     42 +		selmon->sel->sfh = selmon->sel->h;
     43 +	}
     44  	arrange(selmon);
     45  }
     46