diff options
author | Malfurious <m@lfurio.us> | 2022-02-08 06:52:48 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2023-06-03 22:13:52 -0400 |
commit | 1a4d4b0f6cd663c3dee2b6167993cd709cfc91cc (patch) | |
tree | 0879ac32539b494e6a6a60791457e000945fbecd | |
parent | 79176c73bd70292a52739b6c3ff8a354b084a67c (diff) | |
download | dwm-1a4d4b0f6cd663c3dee2b6167993cd709cfc91cc.tar.gz dwm-1a4d4b0f6cd663c3dee2b6167993cd709cfc91cc.zip |
patch: resetlayout
Resets the layout and mfact if there is only one client visible. This
is an edited patch that also resets nmaster to its default value as
well.
This applies cleanly to vanilla dwm, but is mostly only useful alongside
the pertag patch, since otherwise all layouts and mfacts will be reset.
You can also set a binding to trigger this on demand, see the new call
to resetlayout in config.def.h.
-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); |