sites

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

dwm-savefloats-6.1.diff (1605B)


      1 URL: http://dwm.suckless.org/patches/historical/save_floats
      2 This patch saves size and position of every floating window before it is forced
      3 into tiled mode. If the window is made floating again, the old dimensions will
      4 be restored.
      5 
      6 Index: dwm/dwm.c
      7 ===================================================================
      8 --- dwm/dwm.c.orig	2014-02-09 15:24:10.344116918 +0100
      9 +++ dwm/dwm.c	2014-02-09 15:24:10.336116918 +0100
     10 @@ -87,6 +87,7 @@
     11  	char name[256];
     12  	float mina, maxa;
     13  	int x, y, w, h;
     14 +	int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */
     15  	int oldx, oldy, oldw, oldh;
     16  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     17  	int bw, oldbw;
     18 @@ -1045,6 +1046,10 @@
     19  	updatewindowtype(c);
     20  	updatesizehints(c);
     21  	updatewmhints(c);
     22 +	c->sfx = c->x;
     23 +	c->sfy = c->y;
     24 +	c->sfw = c->w;
     25 +	c->sfh = c->h;
     26  	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
     27  	grabbuttons(c, False);
     28  	if(!c->isfloating)
     29 @@ -1641,8 +1646,16 @@
     30  		return;
     31  	selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
     32  	if(selmon->sel->isfloating)
     33 -		resize(selmon->sel, selmon->sel->x, selmon->sel->y,
     34 -		       selmon->sel->w, selmon->sel->h, False);
     35 +		/*restore last known float dimensions*/
     36 +		resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy,
     37 +		       selmon->sel->sfw, selmon->sel->sfh, False);
     38 +	else {
     39 +		/*save last known float dimensions*/
     40 +		selmon->sel->sfx = selmon->sel->x;
     41 +		selmon->sel->sfy = selmon->sel->y;
     42 +		selmon->sel->sfw = selmon->sel->w;
     43 +		selmon->sel->sfh = selmon->sel->h;
     44 +	}
     45  	arrange(selmon);
     46  }
     47