diff --git a/dwm.c b/dwm.c index 67c6b2b..ed46374 100644 --- a/dwm.c +++ b/dwm.c @@ -88,6 +88,7 @@ struct Client { char name[256]; float mina, maxa; int x, y, w, h; + int sfx, sfy, sfw, sfh; /* stored float geometry, used on mode revert */ int oldx, oldy, oldw, oldh; int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; @@ -1068,6 +1069,12 @@ manage(Window w, XWindowAttributes *wa) updatewindowtype(c); updatesizehints(c); updatewmhints(c); + c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; + c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; + c->sfx = c->x; + c->sfy = c->y; + c->sfw = c->w; + c->sfh = c->h; XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); grabbuttons(c, 0); if (!c->isfloating) @@ -1730,8 +1737,16 @@ togglefloating(const Arg *arg) 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, 0); + /* restore last known float dimensions */ + resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy, + selmon->sel->sfw, selmon->sel->sfh, False); + else { + /* save last known float dimensions */ + selmon->sel->sfx = selmon->sel->x; + selmon->sel->sfy = selmon->sel->y; + selmon->sel->sfw = selmon->sel->w; + selmon->sel->sfh = selmon->sel->h; + } arrange(selmon); }