diff --git a/client.c b/client.c index a105514..b779c06 100644 --- a/client.c +++ b/client.c @@ -185,11 +185,12 @@ manage(Window w, XWindowAttributes *wa) { c = emallocz(sizeof(Client)); c->tags = emallocz(ntags * sizeof(Bool)); + c->ftview = True; c->win = w; - c->x = wa->x; - c->y = wa->y; - c->w = wa->width; - c->h = wa->height; + c->x = c->rx = wa->x; + c->y = c->ry = wa->y; + c->w = c->rw = wa->width; + c->h = c->rh = wa->height; c->oldborder = wa->border_width; if(c->w == sw && c->h == sh) { c->x = sx; @@ -198,13 +199,13 @@ manage(Window w, XWindowAttributes *wa) { } else { if(c->x + c->w + 2 * c->border > wax + waw) - c->x = wax + waw - c->w - 2 * c->border; + c->x = c->rx = wax + waw - c->w - 2 * c->border; if(c->y + c->h + 2 * c->border > way + wah) - c->y = way + wah - c->h - 2 * c->border; + c->y = c->ry = way + wah - c->h - 2 * c->border; if(c->x < wax) - c->x = wax; + c->x = c->rx = wax; if(c->y < way) - c->y = way; + c->y = c->ry = way; c->border = BORDERPX; } wc.border_width = c->border; diff --git a/dwm.h b/dwm.h index 1a12322..7d2540d 100644 --- a/dwm.h +++ b/dwm.h @@ -56,6 +56,7 @@ struct Client { Client *prev; Client *snext; Window win; + Bool ftview; /* first time viewed on new layout */ }; typedef struct { diff --git a/screen.c b/screen.c index 8d04911..827f68c 100644 --- a/screen.c +++ b/screen.c @@ -48,7 +48,12 @@ floating(void) { /* default floating layout */ for(c = clients; c; c = c->next) if(isvisible(c)) - resize(c, c->x, c->y, c->w, c->h, True); + if (c->ftview) { + resize(c, c->rx, c->ry, c->rw, c->rh, True); + c->ftview = False; + } + else + resize(c, c->x, c->y, c->w, c->h, True); } LAYOUTS @@ -239,6 +244,7 @@ restack(void) { void setlayout(const char *arg) { unsigned int i; + Client *c; if(!arg) { if(++ltidx == nlayouts) @@ -252,6 +258,8 @@ setlayout(const char *arg) { return; ltidx = i; } + for(c = clients; c; c = c->next) + c->ftview = True; if(sel) arrange(); else @@ -288,7 +296,14 @@ togglefloating(const char *arg) { return; sel->isfloating = !sel->isfloating; if(sel->isfloating) - resize(sel, sel->x, sel->y, sel->w, sel->h, True); + resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); + else { + sel->rx = sel->x; + sel->ry = sel->y; + sel->rw = sel->w; + sel->rh = sel->h; + } + arrange(); } diff --git a/tile.c b/tile.c index 114e84c..9a84987 100644 --- a/tile.c +++ b/tile.c @@ -63,6 +63,13 @@ tile(void) { else nh = th - 2 * c->border; } + if (c->ftview) { + c->rx = c->x; + c->ry = c->y; + c->rw = c->w; + c->rh = c->h; + c->ftview = False; + } resize(c, nx, ny, nw, nh, False); if(n > 1 && th != wah) ny += nh + 2 * c->border;