[wiki] [sites] patches: Add resetlayout patch || Chris Down

From: <git_AT_suckless.org>
Date: Sat, 02 May 2020 19:10:15 +0200

commit 847586dc0b3b0292eeef69474e2b25dd527ad00e
Author: Chris Down <chris_AT_chrisdown.name>
Date: Mon Apr 20 13:55:40 2020 +0100

    patches: Add resetlayout patch

diff --git a/dwm.suckless.org/patches/resetlayout/dwm-resetlayout-20200420-c82db69.diff b/dwm.suckless.org/patches/resetlayout/dwm-resetlayout-20200420-c82db69.diff
new file mode 100644
index 00000000..61097aff
--- /dev/null
+++ b/dwm.suckless.org/patches/resetlayout/dwm-resetlayout-20200420-c82db69.diff
_AT_@ -0,0 +1,52 @@
+diff --git config.def.h config.def.h
+index 1c0b587..eb823d3 100644
+--- config.def.h
++++ config.def.h
+_AT_@ -70,6 +70,7 @@ static 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, XK_Return, zoom, {0} },
+ { MODKEY, XK_Tab, view, {0} },
+ { MODKEY|ShiftMask, XK_c, killclient, {0} },
+diff --git dwm.c dwm.c
+index 4465af1..75fe777 100644
+--- dwm.c
++++ dwm.c
+_AT_@ -188,6 +188,7 @@ static void pop(Client *);
+ static void propertynotify(XEvent *e);
+ 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);
+_AT_@ -1265,6 +1266,16 @@ recttomon(int x, int y, int w, int h)
+ return r;
+ }
+
++void
++resetlayout(const Arg *arg)
++{
++ Arg default_layout = {.v = &layouts[0]};
++ Arg default_mfact = {.f = mfact + 1};
++
++ setlayout(&default_layout);
++ setmfact(&default_mfact);
++}
++
+ void
+ resize(Client *c, int x, int y, int w, int h, int interact)
+ {
+_AT_@ -1282,6 +1293,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);
diff --git a/dwm.suckless.org/patches/resetlayout/index.md b/dwm.suckless.org/patches/resetlayout/index.md
new file mode 100644
index 00000000..e00b2fd7
--- /dev/null
+++ b/dwm.suckless.org/patches/resetlayout/index.md
_AT_@ -0,0 +1,22 @@
+resetlayout
+===========
+
+Description
+-----------
+
+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](../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.
+
+Download
+--------
+* [dwm-attachaside-20200420-c82db69.diff](dwm-resetlayout-20200420-c82db69.diff)
+
+Authors
+-------
+* Chris Down - <chris_AT_chrisdown.name>
Received on Sat May 02 2020 - 19:10:15 CEST

This archive was generated by hypermail 2.3.0 : Sat May 02 2020 - 19:12:47 CEST