Hi,
I updated Jan Christoph Ebersbach's save_floats.patch to dwm hg tip
and improved it a bit. I think it makes sense to push it to hg tip,
because it implements the naturally expected behaviour of floating
windows and saves you a lot of unnecessary work when working frequently
with floating windows.

Matthias-Christian
diff -r cd4a51f33228 dwm.c
--- a/dwm.c     Mon Mar 31 10:09:48 2008 +0100
+++ b/dwm.c     Mon Mar 31 19:56:45 2008 +0200
@@ -66,6 +66,7 @@
 struct Client {
        char name[256];
        int x, y, w, h;
+       int fx, fy, fw, fh;
        int basew, baseh, incw, inch, maxw, maxh, minw, minh;
        int minax, maxax, minay, maxay;
        long flags;
@@ -675,7 +676,10 @@
 
        for(c = clients; c; c = c->next)
                if(isvisible(c))
-                       resize(c, c->x, c->y, c->w, c->h, True);
+                       if(!c->isfloating)
+                               resize(c, c->fx, c->fy, c->fw, c->fh, True);
+                       else
+                               resize(c, c->x, c->y, c->w, c->h, True);
 }
 
 void
@@ -1039,6 +1043,10 @@
        XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
        configure(c); /* propagates border_width, if size doesn't change */
        updatesizehints(c);
+       c->fx = c->x;
+       c->fy = c->y;
+       c->fw = c->w;
+       c->fh = c->h;
        XSelectInput(dpy, w, 
EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
        grabbuttons(c, False);
        updatetitle(c);
@@ -1128,8 +1136,11 @@
                                ny = wy + wh - c->h - 2 * c->bw;
                        if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) 
> SNAP || abs(ny - c->y) > SNAP))
                                togglefloating(NULL);
-                       if((lt->isfloating) || c->isfloating)
+                       if((lt->isfloating) || c->isfloating) {
+                               c->fx = nx;
+                               c->fy = ny;
                                resize(c, nx, ny, c->w, c->h, False);
+                       }
                        break;
                }
        }
@@ -1289,8 +1300,11 @@
                                nh = 1;
                        if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) 
> SNAP || abs(nh - c->h) > SNAP))
                                togglefloating(NULL);
-                       if((lt->isfloating) || c->isfloating)
+                       if((lt->isfloating) || c->isfloating) {
+                               c->fw = nw;
+                               c->fh = nh;
                                resize(c, c->x, c->y, nw, nh, True);
+                       }
                        break;
                }
        }
@@ -1708,7 +1722,13 @@
                return;
        sel->isfloating = !sel->isfloating;
        if(sel->isfloating)
-               resize(sel, sel->x, sel->y, sel->w, sel->h, True);
+               resize(sel, sel->fx, sel->fy, sel->fw, sel->fh, True);
+       else {
+               sel->fx = sel->x;
+               sel->fy = sel->y;
+               sel->fw = sel->w;
+               sel->fh = sel->h;
+       }
        arrange();
 }
 

Reply via email to