summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-02-29 11:52:31 -0500
committerMatt Hunter <m@lfurio.us>2026-01-18 00:18:46 -0500
commitcc76324a76064f130d0bdce6b6af266162774b60 (patch)
treea052dd100e7b1c3a93cbe991e80e9003cb1c117a /dwm.c
parentbeed57c13b21878f27778d3e76dd60f656fe9092 (diff)
downloaddwm-cc76324a76064f130d0bdce6b6af266162774b60.tar.gz
dwm-cc76324a76064f130d0bdce6b6af266162774b60.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 6d2c4fd..d8f0f96 100644
--- a/dwm.c
+++ b/dwm.c
@@ -201,6 +201,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);
@@ -1490,6 +1491,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