summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-02-29 11:52:31 -0500
committerMalfurious <m@lfurio.us>2024-03-05 21:04:47 -0500
commitc487d2524a1c8429b74285ef05557fb408483da0 (patch)
treeea0c93a2e074ec022b4c4b99d45ceb315f5f8f7a /dwm.c
parent5746fa052056ef9d254996597b63ad0757c1e9cc (diff)
downloaddwm-c487d2524a1c8429b74285ef05557fb408483da0.tar.gz
dwm-c487d2524a1c8429b74285ef05557fb408483da0.zip
patch: resetlayout
Resets the layout and mfact if there is only one client visible. 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. This patch also resets nmaster to its default value as well.
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index 51736fe..11bce9a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -202,6 +202,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);
@@ -1491,6 +1492,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))
@@ -2062,6 +2075,9 @@ unmanage(Client *c, int destroyed)
focus(NULL);
updateclientlist();
arrange(m);
+
+ if (nexttiled(m->clients) == NULL)
+ resetlayout(NULL);
}
void