I really loved the "historical" save floats patch.

Here is my own patch against 72e52c5333ef (should work against
5.7.2 too). Comments are welcome.
diff -r 72e52c5333ef dwm.c
--- a/dwm.c	Wed Nov 25 13:56:17 2009 +0000
+++ b/dwm.c	Sat Feb 13 12:53:08 2010 +0100
@@ -83,6 +83,7 @@
 	char name[256];
 	float mina, maxa;
 	int x, y, w, h;
+	int ox, oy, ow, oh;
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int bw, oldbw;
 	unsigned int tags;
@@ -203,6 +204,7 @@
 static void resizemouse(const Arg *arg);
 static void restack(Monitor *m);
 static void run(void);
+static void savefloat(Client *c);
 static void scan(void);
 static void sendmon(Client *c, Monitor *m);
 static void setclientstate(Client *c, long state);
@@ -811,6 +813,14 @@
 }
 
 void
+savefloat(Client *c) {
+	c->ox = c->x;
+	c->oy = c->y;
+	c->ow = c->w;
+	c->oh = c->h;
+}
+
+void
 focus(Client *c) {
 	if(!c || !ISVISIBLE(c))
 		for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
@@ -1130,6 +1140,7 @@
 		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
 		c->bw = borderpx;
 	}
+    savefloat(c);
 	wc.border_width = c->bw;
 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
 	XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
@@ -1447,10 +1458,18 @@
 
 void
 setlayout(const Arg *arg) {
+	Client *c;
+
+    if (!selmon->lt[selmon->sellt]->arrange)
+        for(c = selmon->clients; c; c = c->next)
+            savefloat(c);
 	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
 		selmon->sellt ^= 1;
 	if(arg && arg->v)
 		selmon->lt[selmon->sellt] = (Layout *)arg->v;
+    if (!selmon->lt[selmon->sellt]->arrange)
+        for(c = selmon->clients; c; c = c->next)
+            resize(c, c->ox, c->oy, c->ow, c->oh, False);
 	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
 	if(selmon->sel)
 		arrange(selmon);
@@ -1631,9 +1650,13 @@
 	if(!selmon->sel)
 		return;
 	selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
-	if(selmon->sel->isfloating)
-		resize(selmon->sel, selmon->sel->x, selmon->sel->y,
-		       selmon->sel->w, selmon->sel->h, False);
+	if(selmon->sel->isfloating) {
+		resize(selmon->sel, selmon->sel->ox, selmon->sel->oy,
+		       selmon->sel->ow, selmon->sel->oh, False);
+	}
+	else {
+		savefloat(selmon->sel);
+	}
 	arrange(selmon);
 }
 

Reply via email to