diff options
-rw-r--r-- | config.def.h | 1 | ||||
-rw-r--r-- | dwm.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 96df03e..bb67a43 100644 --- a/config.def.h +++ b/config.def.h @@ -87,6 +87,7 @@ static const Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_r, resetlayout, {0} }, { MODKEY|ShiftMask, XK_j, pushdown, {0} }, { MODKEY|ShiftMask, XK_k, pushup, {0} }, { MODKEY, XK_Return, zoom, {0} }, @@ -197,6 +197,7 @@ static void pushdown(const Arg *arg); static void pushup(const Arg *arg); static void quit(const Arg *arg); static Monitor *recttomon(int x, int y, int w, int h); +static void resetlayout(const Arg *arg); static void resize(Client *c, int x, int y, int w, int h, int interact); static void resizeclient(Client *c, int x, int y, int w, int h); static void resizemouse(const Arg *arg); @@ -1389,6 +1390,18 @@ recttomon(int x, int y, int w, int h) } void +resetlayout(const Arg *arg) +{ + Arg default_layout = {.v = &layouts[0]}; + Arg default_mfact = {.f = mfact + 1}; + Arg default_nmaster = {.i = nmaster - selmon->nmaster}; + + setlayout(&default_layout); + setmfact(&default_mfact); + incnmaster(&default_nmaster); +} + +void resize(Client *c, int x, int y, int w, int h, int interact) { if (applysizehints(c, &x, &y, &w, &h, interact)) @@ -1405,6 +1418,10 @@ resizeclient(Client *c, int x, int y, int w, int h) c->oldw = c->w; c->w = wc.width = w; c->oldh = c->h; c->h = wc.height = h; wc.border_width = c->bw; + + if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next))) + resetlayout(NULL); + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); configure(c); XSync(dpy, False); |