diff --git a/dwm.c b/dwm.c index cfea881..87a23c4 100644 --- a/dwm.c +++ b/dwm.c @@ -107,6 +107,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; int bw, oldbw; @@ -1205,10 +1206,10 @@ manage(Window w, XWindowAttributes *wa) c = ecalloc(1, sizeof(Client)); c->win = w; /* geometry */ - c->x = c->oldx = wa->x; - c->y = c->oldy = wa->y; - c->w = c->oldw = wa->width; - c->h = c->oldh = wa->height; + c->sfx = c->x = c->oldx = wa->x; + c->sfy = c->y = c->oldy = wa->y; + c->sfw = c->w = c->oldw = wa->width; + c->sfh = c->h = c->oldh = wa->height; c->oldbw = wa->border_width; updatetitle(c); @@ -1976,8 +1977,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 know float dimentions */ + resize(selmon->sel, selmon->sel->sfx, selmon->sel->sfy, + selmon->sel->sfw, selmon->sel->sfh, 0); + else { + /* save last known float dimentions */ + 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); }