summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-08-16 18:44:43 +0300
committerxAlpharax <42233094+xAlpharax@users.noreply.github.com>2023-08-16 18:44:43 +0300
commit1dec076282eae69d44e5aa3168ae8ed0e7bfb94d (patch)
treebba9b2448b4d07c7df79898d31ec6c6327a21bf0 /patches
parent15346749a4ce015906ed1a98f60c335cf8c07745 (diff)
Patched dwm according to current configuration.
Changes to be committed: modified: config.def.h new file: config.def.h.orig new file: config.def.h.rej new file: config.h new file: drw.c.orig modified: dwm.1 new file: dwm.1.orig modified: dwm.c new file: dwm.c.orig new file: dwm.c.rej new file: movestack.c new file: patches/dwm-actualfullscreen-20211013-cb3f58a.diff new file: patches/dwm-adjacenttag-skipvacant-6.2.diff new file: patches/dwm-alttagsdecoration-2020010304-cb3f58a.diff new file: patches/dwm-alwayscenter-20200625-f04cac6.diff new file: patches/dwm-attachbottom-6.3.diff new file: patches/dwm-fixborders-6.2.diff new file: patches/dwm-movestack-20211115-a786211.diff new file: patches/dwm-pertag-20200914-61bb8b2.diff new file: patches/dwm-uselessgap-20211119-58414bee958f2.diff
Diffstat (limited to 'patches')
-rw-r--r--patches/dwm-actualfullscreen-20211013-cb3f58a.diff68
-rw-r--r--patches/dwm-adjacenttag-skipvacant-6.2.diff161
-rw-r--r--patches/dwm-alttagsdecoration-2020010304-cb3f58a.diff67
-rw-r--r--patches/dwm-alwayscenter-20200625-f04cac6.diff12
-rw-r--r--patches/dwm-attachbottom-6.3.diff54
-rw-r--r--patches/dwm-fixborders-6.2.diff27
-rw-r--r--patches/dwm-movestack-20211115-a786211.diff95
-rw-r--r--patches/dwm-pertag-20200914-61bb8b2.diff177
-rw-r--r--patches/dwm-uselessgap-20211119-58414bee958f2.diff101
9 files changed, 762 insertions, 0 deletions
diff --git a/patches/dwm-actualfullscreen-20211013-cb3f58a.diff b/patches/dwm-actualfullscreen-20211013-cb3f58a.diff
new file mode 100644
index 0000000..d3be230
--- /dev/null
+++ b/patches/dwm-actualfullscreen-20211013-cb3f58a.diff
@@ -0,0 +1,68 @@
+From eea13010ffc3983392857ee1e3804e3aa1064d7a Mon Sep 17 00:00:00 2001
+From: Soenke Lambert <s.lambert@mittwald.de>
+Date: Wed, 13 Oct 2021 18:21:09 +0200
+Subject: [PATCH] Fullscreen current window with [Alt]+[Shift]+[f]
+
+This actually fullscreens a window, instead of just hiding the statusbar
+and applying the monocle layout.
+---
+ config.def.h | 1 +
+ dwm.1 | 3 +++
+ dwm.c | 8 ++++++++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..8cd3204 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -78,6 +78,7 @@ static Key keys[] = {
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
++ { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+ { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+ { MODKEY, XK_comma, focusmon, {.i = -1 } },
+diff --git a/dwm.1 b/dwm.1
+index 13b3729..a368d05 100644
+--- a/dwm.1
++++ b/dwm.1
+@@ -116,6 +116,9 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
+ .B Mod1\-Shift\-c
+ Close focused window.
+ .TP
++.B Mod1\-Shift\-f
++Toggle fullscreen for focused window.
++.TP
+ .B Mod1\-Shift\-space
+ Toggle focused window between tiled and floating state.
+ .TP
+diff --git a/dwm.c b/dwm.c
+index 4465af1..c1b899a 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglefullscr(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+@@ -1719,6 +1720,13 @@ togglefloating(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++togglefullscr(const Arg *arg)
++{
++ if(selmon->sel)
++ setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
++}
++
+ void
+ toggletag(const Arg *arg)
+ {
+--
+2.30.2
+
diff --git a/patches/dwm-adjacenttag-skipvacant-6.2.diff b/patches/dwm-adjacenttag-skipvacant-6.2.diff
new file mode 100644
index 0000000..6e39d71
--- /dev/null
+++ b/patches/dwm-adjacenttag-skipvacant-6.2.diff
@@ -0,0 +1,161 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2021-10-02 14:22:28.034782413 +0100
++++ b/config.def.h 2021-10-02 14:22:28.044723532 +0100
+@@ -84,6 +84,10 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_Right, viewnext, {0} },
++ { MODKEY, XK_Left, viewprev, {0} },
++ { MODKEY|ShiftMask, XK_Right, tagtonext, {0} },
++ { MODKEY|ShiftMask, XK_Left, tagtoprev, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2021-10-02 14:22:28.034782413 +0100
++++ b/dwm.c 2021-10-02 14:27:54.599845767 +0100
+@@ -183,8 +183,10 @@ static void maprequest(XEvent *e);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static unsigned int nexttag(void);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *);
++static unsigned int prevtag(void);
+ static void propertynotify(XEvent *e);
+ static void quit(const Arg *arg);
+ static Monitor *recttomon(int x, int y, int w, int h);
+@@ -208,6 +210,8 @@ static void sigchld(int unused);
+ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
++static void tagtonext(const Arg *arg);
++static void tagtoprev(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+@@ -227,6 +231,8 @@ static void updatetitle(Client *c);
+ static void updatewindowtype(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
++static void viewnext(const Arg *arg);
++static void viewprev(const Arg *arg);
+ static Client *wintoclient(Window w);
+ static Monitor *wintomon(Window w);
+ static int xerror(Display *dpy, XErrorEvent *ee);
+@@ -1192,6 +1198,29 @@ movemouse(const Arg *arg)
+ }
+ }
+
++unsigned int
++nexttag(void)
++{
++ unsigned int seltag = selmon->tagset[selmon->seltags];
++ unsigned int usedtags = 0;
++ Client *c = selmon->clients;
++
++ if (!c)
++ return seltag;
++
++ /* skip vacant tags */
++ do {
++ usedtags |= c->tags;
++ c = c->next;
++ } while (c);
++
++ do {
++ seltag = seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
++ } while (!(seltag & usedtags));
++
++ return seltag;
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
+@@ -1208,6 +1237,28 @@ pop(Client *c)
+ arrange(c->mon);
+ }
+
++unsigned int
++prevtag(void)
++{
++ unsigned int seltag = selmon->tagset[selmon->seltags];
++ unsigned int usedtags = 0;
++ Client *c = selmon->clients;
++ if (!c)
++ return seltag;
++
++ /* skip vacant tags */
++ do {
++ usedtags |= c->tags;
++ c = c->next;
++ } while (c);
++
++ do {
++ seltag = seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
++ } while (!(seltag & usedtags));
++
++ return seltag;
++}
++
+ void
+ propertynotify(XEvent *e)
+ {
+@@ -1671,6 +1722,36 @@ tagmon(const Arg *arg)
+ }
+
+ void
++tagtonext(const Arg *arg)
++{
++ unsigned int tmp;
++
++ if (selmon->sel == NULL)
++ return;
++
++ if ((tmp = nexttag()) == selmon->tagset[selmon->seltags])
++ return;
++
++ tag(&(const Arg){.ui = tmp });
++ view(&(const Arg){.ui = tmp });
++}
++
++void
++tagtoprev(const Arg *arg)
++{
++ unsigned int tmp;
++
++ if (selmon->sel == NULL)
++ return;
++
++ if ((tmp = prevtag()) == selmon->tagset[selmon->seltags])
++ return;
++
++ tag(&(const Arg){.ui = tmp });
++ view(&(const Arg){.ui = tmp });
++}
++
++void
+ tile(Monitor *m)
+ {
+ unsigned int i, n, h, mw, my, ty;
+@@ -2044,6 +2125,18 @@ view(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++viewnext(const Arg *arg)
++{
++ view(&(const Arg){.ui = nexttag()});
++}
++
++void
++viewprev(const Arg *arg)
++{
++ view(&(const Arg){.ui = prevtag()});
++}
++
+ Client *
+ wintoclient(Window w)
+ {
diff --git a/patches/dwm-alttagsdecoration-2020010304-cb3f58a.diff b/patches/dwm-alttagsdecoration-2020010304-cb3f58a.diff
new file mode 100644
index 0000000..fcbc1ef
--- /dev/null
+++ b/patches/dwm-alttagsdecoration-2020010304-cb3f58a.diff
@@ -0,0 +1,67 @@
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..d4b11fc 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -20,6 +20,7 @@ static const char *colors[][3] = {
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
++static const char *alttags[] = { "<01>", "<02>", "<03>", "<04>", "<05>" };
+
+ static const Rule rules[] = {
+ /* xprop(1):
+diff --git a/dwm.c b/dwm.c
+index 4465af1..a394159 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -416,7 +416,7 @@ attachstack(Client *c)
+ void
+ buttonpress(XEvent *e)
+ {
+- unsigned int i, x, click;
++ unsigned int i, x, click, occ;
+ Arg arg = {0};
+ Client *c;
+ Monitor *m;
+@@ -430,9 +430,13 @@ buttonpress(XEvent *e)
+ focus(NULL);
+ }
+ if (ev->window == selmon->barwin) {
+- i = x = 0;
++ i = x = occ = 0;
++ /* Bitmask of occupied tags */
++ for (c = m->clients; c; c = c->next)
++ occ |= c->tags;
++
+ do
+- x += TEXTW(tags[i]);
++ x += TEXTW(occ & 1 << i ? alttags[i] : tags[i]);
+ while (ev->x >= x && ++i < LENGTH(tags));
+ if (i < LENGTH(tags)) {
+ click = ClkTagBar;
+@@ -699,6 +703,7 @@ drawbar(Monitor *m)
+ int boxs = drw->fonts->h / 9;
+ int boxw = drw->fonts->h / 6 + 2;
+ unsigned int i, occ = 0, urg = 0;
++ const char *tagtext;
+ Client *c;
+
+ /* draw status first so it can be overdrawn by tags later */
+@@ -715,13 +720,10 @@ drawbar(Monitor *m)
+ }
+ x = 0;
+ for (i = 0; i < LENGTH(tags); i++) {
+- w = TEXTW(tags[i]);
+- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+- if (occ & 1 << i)
+- drw_rect(drw, x + boxs, boxs, boxw, boxw,
+- m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+- urg & 1 << i);
++ tagtext = occ & 1 << i ? alttags[i] : tags[i];
++ w = TEXTW(tagtext);
++ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
++ drw_text(drw, x, 0, w, bh, lrpad / 2, tagtext, urg & 1 << i);
+ x += w;
+ }
+ w = blw = TEXTW(m->ltsymbol);
diff --git a/patches/dwm-alwayscenter-20200625-f04cac6.diff b/patches/dwm-alwayscenter-20200625-f04cac6.diff
new file mode 100644
index 0000000..03ea9ef
--- /dev/null
+++ b/patches/dwm-alwayscenter-20200625-f04cac6.diff
@@ -0,0 +1,12 @@
+diff -up dwm/dwm.c dwmmod/dwm.c
+--- dwm/dwm.c 2020-06-25 00:21:30.383692180 -0300
++++ dwmmod/dwm.c 2020-06-25 00:20:35.643692330 -0300
+@@ -1057,6 +1057,8 @@ manage(Window w, XWindowAttributes *wa)
+ updatewindowtype(c);
+ updatesizehints(c);
+ updatewmhints(c);
++ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
++ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
+ XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
+ grabbuttons(c, 0);
+ if (!c->isfloating)
diff --git a/patches/dwm-attachbottom-6.3.diff b/patches/dwm-attachbottom-6.3.diff
new file mode 100644
index 0000000..c3955f9
--- /dev/null
+++ b/patches/dwm-attachbottom-6.3.diff
@@ -0,0 +1,54 @@
+diff -up dwm-6.3/dwm.c dwm-6.3-attachbottom/dwm.c
+--- dwm-6.3/dwm.c 2022-01-07 12:42:18.000000000 +0100
++++ dwm-6.3-attachbottom/dwm.c 2022-08-17 22:14:41.813809073 +0200
+@@ -147,6 +147,7 @@ static int applysizehints(Client *c, int
+ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
++static void attachbottom(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+@@ -408,6 +409,15 @@ attach(Client *c)
+ }
+
+ void
++attachbottom(Client *c)
++{
++ Client **tc;
++ c->next = NULL;
++ for (tc = &c->mon->clients; *tc; tc = &(*tc)->next);
++ *tc = c;
++}
++
++void
+ attachstack(Client *c)
+ {
+ c->snext = c->mon->stack;
+@@ -1066,7 +1076,7 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ attachbottom(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &(c->win), 1);
+@@ -1421,7 +1431,7 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ attachbottom(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+@@ -1903,7 +1913,7 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ attachbottom(c);
+ attachstack(c);
+ }
+ if (m == selmon)
diff --git a/patches/dwm-fixborders-6.2.diff b/patches/dwm-fixborders-6.2.diff
new file mode 100644
index 0000000..0a17b9e
--- /dev/null
+++ b/patches/dwm-fixborders-6.2.diff
@@ -0,0 +1,27 @@
+From 1529909466206016f2101457bbf37c67195714c8 Mon Sep 17 00:00:00 2001
+From: Jakub Leszczak <szatan@gecc.xyz>
+Date: Fri, 22 Nov 2019 10:46:53 +0800
+Subject: [PATCH] Fix transparent borders
+
+When terminal has transparency then its borders also become transparent.
+Fix it by removing transparency from any pixels drawn.
+---
+ drw.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drw.c b/drw.c
+index 8fd1ca4..490a592 100644
+--- a/drw.c
++++ b/drw.c
+@@ -202,6 +202,8 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
+ DefaultColormap(drw->dpy, drw->screen),
+ clrname, dest))
+ die("error, cannot allocate color '%s'", clrname);
++
++ dest->pixel |= 0xff << 24;
+ }
+
+ /* Wrapper to create color schemes. The caller has to call free(3) on the
+--
+2.26.2
+
diff --git a/patches/dwm-movestack-20211115-a786211.diff b/patches/dwm-movestack-20211115-a786211.diff
new file mode 100644
index 0000000..134abb8
--- /dev/null
+++ b/patches/dwm-movestack-20211115-a786211.diff
@@ -0,0 +1,95 @@
+From 9a4037dc0ef56f91c009317e78e9e3790dafbb58 Mon Sep 17 00:00:00 2001
+From: BrunoCooper17 <BrunoCooper17@outlook.com>
+Date: Mon, 15 Nov 2021 14:04:53 -0600
+Subject: [PATCH] MoveStack patch
+
+This plugin allows you to move clients around in the stack and swap them
+with the master. It emulates the behavior off mod+shift+j and mod+shift+k
+in Xmonad. movestack(+1) will swap the client with the current focus with
+the next client. movestack(-1) will swap the client with the current focus
+with the previous client.
+---
+ config.def.h | 3 +++
+ movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 51 insertions(+)
+ create mode 100644 movestack.c
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..33efa5b 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -60,6 +60,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
+ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+ static const char *termcmd[] = { "st", NULL };
+
++#include "movestack.c"
+ static Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+@@ -71,6 +72,8 @@ static Key keys[] = {
+ { MODKEY, XK_d, incnmaster, {.i = -1 } },
+ { MODKEY, XK_h, setmfact, {.f = -0.05} },
+ { MODKEY, XK_l, setmfact, {.f = +0.05} },
++ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
++ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
+ { MODKEY, XK_Return, zoom, {0} },
+ { MODKEY, XK_Tab, view, {0} },
+ { MODKEY|ShiftMask, XK_c, killclient, {0} },
+diff --git a/movestack.c b/movestack.c
+new file mode 100644
+index 0000000..520f4ae
+--- /dev/null
++++ b/movestack.c
+@@ -0,0 +1,48 @@
++void
++movestack(const Arg *arg) {
++ Client *c = NULL, *p = NULL, *pc = NULL, *i;
++
++ if(arg->i > 0) {
++ /* find the client after selmon->sel */
++ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
++ if(!c)
++ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
++
++ }
++ else {
++ /* find the client before selmon->sel */
++ for(i = selmon->clients; i != selmon->sel; i = i->next)
++ if(ISVISIBLE(i) && !i->isfloating)
++ c = i;
++ if(!c)
++ for(; i; i = i->next)
++ if(ISVISIBLE(i) && !i->isfloating)
++ c = i;
++ }
++ /* find the client before selmon->sel and c */
++ for(i = selmon->clients; i && (!p || !pc); i = i->next) {
++ if(i->next == selmon->sel)
++ p = i;
++ if(i->next == c)
++ pc = i;
++ }
++
++ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
++ if(c && c != selmon->sel) {
++ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
++ selmon->sel->next = c->next==selmon->sel?c:c->next;
++ c->next = temp;
++
++ if(p && p != c)
++ p->next = c;
++ if(pc && pc != selmon->sel)
++ pc->next = selmon->sel;
++
++ if(selmon->sel == selmon->clients)
++ selmon->clients = c;
++ else if(c == selmon->clients)
++ selmon->clients = selmon->sel;
++
++ arrange(selmon);
++ }
++}
+\ No newline at end of file
+--
+2.33.1
+
diff --git a/patches/dwm-pertag-20200914-61bb8b2.diff b/patches/dwm-pertag-20200914-61bb8b2.diff
new file mode 100644
index 0000000..c8d7fbc
--- /dev/null
+++ b/patches/dwm-pertag-20200914-61bb8b2.diff
@@ -0,0 +1,177 @@
+diff --git a/dwm.c b/dwm.c
+index 664c527..ac8e4ec 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -111,6 +111,7 @@ typedef struct {
+ void (*arrange)(Monitor *);
+ } Layout;
+
++typedef struct Pertag Pertag;
+ struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+@@ -130,6 +131,7 @@ struct Monitor {
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
++ Pertag *pertag;
+ };
+
+ typedef struct {
+@@ -272,6 +274,15 @@ static Window root, wmcheckwin;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++struct Pertag {
++ unsigned int curtag, prevtag; /* current and previous tag */
++ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
++ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
++ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
++ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
++ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
++};
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+@@ -632,6 +643,7 @@ Monitor *
+ createmon(void)
+ {
+ Monitor *m;
++ unsigned int i;
+
+ m = ecalloc(1, sizeof(Monitor));
+ m->tagset[0] = m->tagset[1] = 1;
+@@ -642,6 +654,20 @@ createmon(void)
+ m->lt[0] = &layouts[0];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++ m->pertag = ecalloc(1, sizeof(Pertag));
++ m->pertag->curtag = m->pertag->prevtag = 1;
++
++ for (i = 0; i <= LENGTH(tags); i++) {
++ m->pertag->nmasters[i] = m->nmaster;
++ m->pertag->mfacts[i] = m->mfact;
++
++ m->pertag->ltidxs[i][0] = m->lt[0];
++ m->pertag->ltidxs[i][1] = m->lt[1];
++ m->pertag->sellts[i] = m->sellt;
++
++ m->pertag->showbars[i] = m->showbar;
++ }
++
+ return m;
+ }
+
+@@ -967,7 +993,7 @@ grabkeys(void)
+ void
+ incnmaster(const Arg *arg)
+ {
+- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
+ arrange(selmon);
+ }
+
+@@ -1502,9 +1528,9 @@ void
+ setlayout(const Arg *arg)
+ {
+ if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+- selmon->sellt ^= 1;
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
+ if (arg && arg->v)
+- selmon->lt[selmon->sellt] = (Layout *)arg->v;
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+ if (selmon->sel)
+ arrange(selmon);
+@@ -1523,7 +1549,7 @@ setmfact(const Arg *arg)
+ f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
+ if (f < 0.05 || f > 0.95)
+ return;
+- selmon->mfact = f;
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
+ arrange(selmon);
+ }
+
+@@ -1702,7 +1728,7 @@ tile(Monitor *m)
+ void
+ togglebar(const Arg *arg)
+ {
+- selmon->showbar = !selmon->showbar;
++ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
+ updatebarpos(selmon);
+ XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
+ arrange(selmon);
+@@ -1741,9 +1767,33 @@ void
+ toggleview(const Arg *arg)
+ {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
++ int i;
+
+ if (newtagset) {
+ selmon->tagset[selmon->seltags] = newtagset;
++
++ if (newtagset == ~0) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ selmon->pertag->curtag = 0;
++ }
++
++ /* test if the user did not select the same tag */
++ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ for (i = 0; !(newtagset & 1 << i); i++) ;
++ selmon->pertag->curtag = i + 1;
++ }
++
++ /* apply settings for this view */
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
++
++ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
++ togglebar(NULL);
++
+ focus(NULL);
+ arrange(selmon);
+ }
+@@ -2038,11 +2088,37 @@ updatewmhints(Client *c)
+ void
+ view(const Arg *arg)
+ {
++ int i;
++ unsigned int tmptag;
++
+ if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+- if (arg->ui & TAGMASK)
++ if (arg->ui & TAGMASK) {
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++
++ if (arg->ui == ~0)
++ selmon->pertag->curtag = 0;
++ else {
++ for (i = 0; !(arg->ui & 1 << i); i++) ;
++ selmon->pertag->curtag = i + 1;
++ }
++ } else {
++ tmptag = selmon->pertag->prevtag;
++ selmon->pertag->prevtag = selmon->pertag->curtag;
++ selmon->pertag->curtag = tmptag;
++ }
++
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
++
++ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
++ togglebar(NULL);
++
+ focus(NULL);
+ arrange(selmon);
+ }
diff --git a/patches/dwm-uselessgap-20211119-58414bee958f2.diff b/patches/dwm-uselessgap-20211119-58414bee958f2.diff
new file mode 100644
index 0000000..f8a3aec
--- /dev/null
+++ b/patches/dwm-uselessgap-20211119-58414bee958f2.diff
@@ -0,0 +1,101 @@
+From 58414bee958f2e7ed91d6fe31f503ec4a406981b Mon Sep 17 00:00:00 2001
+From: cirala <thim@cederlund.de>
+Date: Fri, 19 Nov 2021 18:14:07 +0100
+Subject: [PATCH] Fix for dwm-uselessgap
+Previous versions of the patch doubles the
+gap between the master and slave stacks.
+
+---
+ config.def.h | 3 ++-
+ dwm.c | 38 +++++++++++++++++++++++++++++++-------
+ 2 files changed, 33 insertions(+), 8 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..17a205f 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,7 @@
+
+ /* appearance */
+ static const unsigned int borderpx = 1; /* border pixel of windows */
++static const unsigned int gappx = 6; /* gaps between windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
+@@ -34,7 +35,7 @@ static const Rule rules[] = {
+ /* layout(s) */
+ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
+ static const int nmaster = 1; /* number of clients in master area */
+-static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
++static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
+ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+
+ static const Layout layouts[] = {
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..b626e89 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -52,8 +52,8 @@
+ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
+ #define LENGTH(X) (sizeof X / sizeof X[0])
+ #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
+-#define WIDTH(X) ((X)->w + 2 * (X)->bw)
+-#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
++#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
++#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
+ #define TAGMASK ((1 << LENGTH(tags)) - 1)
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+@@ -1277,12 +1277,36 @@ void
+ resizeclient(Client *c, int x, int y, int w, int h)
+ {
+ XWindowChanges wc;
++ unsigned int n;
++ unsigned int gapoffset;
++ unsigned int gapincr;
++ Client *nbc;
+
+- c->oldx = c->x; c->x = wc.x = x;
+- c->oldy = c->y; c->y = wc.y = y;
+- c->oldw = c->w; c->w = wc.width = w;
+- c->oldh = c->h; c->h = wc.height = h;
+ wc.border_width = c->bw;
++
++ /* Get number of clients for the client's monitor */
++ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
++
++ /* Do nothing if layout is floating */
++ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
++ gapincr = gapoffset = 0;
++ } else {
++ /* Remove border and gap if layout is monocle or only one client */
++ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
++ gapoffset = 0;
++ gapincr = -2 * borderpx;
++ wc.border_width = 0;
++ } else {
++ gapoffset = gappx;
++ gapincr = 2 * gappx;
++ }
++ }
++
++ c->oldx = c->x; c->x = wc.x = x + gapoffset;
++ c->oldy = c->y; c->y = wc.y = y + gapoffset;
++ c->oldw = c->w; c->w = wc.width = w - gapincr;
++ c->oldh = c->h; c->h = wc.height = h - gapincr;
++
+ XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
+ configure(c);
+ XSync(dpy, False);
+@@ -1688,7 +1712,7 @@ tile(Monitor *m)
+ for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ if (i < m->nmaster) {
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
+- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
++ resize(c, m->wx, m->wy + my, mw - (2*c->bw) + (n > 1 ? gappx : 0), h - (2*c->bw), 0);
+ if (my + HEIGHT(c) < m->wh)
+ my += HEIGHT(c);
+ } else {
+--
+2.33.1
+