aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorc2024-01-12 09:14:30 -0500
committerc2024-01-12 09:14:30 -0500
commit1af4a1e1a94c17fc3de958b74d03bc586248c8b5 (patch)
treede907eeb81a1c0053180e46a25ecae510416b04d
parent05e2bf7b62eb9fe04d104d4a87dbe61c85546b43 (diff)
Oh, were those not in there the whole time?
-rw-r--r--patches/dwm-centeredmaster-6.1.diff142
-rw-r--r--patches/dwm-dragmfact-6.2.diff68
-rw-r--r--patches/dwm-movecenter-6.2.diff39
-rw-r--r--patches/dwm-resizecorners-6.2.diff68
-rw-r--r--patches/dwm-swallow-6.3.diff412
-rw-r--r--patches/dwm-titlecolor-20210815-ed3ab6b4.diff47
6 files changed, 776 insertions, 0 deletions
diff --git a/patches/dwm-centeredmaster-6.1.diff b/patches/dwm-centeredmaster-6.1.diff
new file mode 100644
index 0000000..6926892
--- /dev/null
+++ b/patches/dwm-centeredmaster-6.1.diff
@@ -0,0 +1,142 @@
+diff --git a/config.def.h b/config.def.h
+index 7054c06..527b214 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -39,6 +39,8 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "|M|", centeredmaster },
++ { ">M>", centeredfloatingmaster },
+ };
+
+ /* key definitions */
+@@ -74,6 +76,8 @@ static Key keys[] = {
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
++ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
++ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+diff --git a/dwm.c b/dwm.c
+index 0362114..1e81412 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -233,6 +233,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
+ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
++static void centeredmaster(Monitor *m);
++static void centeredfloatingmaster(Monitor *m);
+
+ /* variables */
+ static const char broken[] = "broken";
+@@ -2139,3 +2141,106 @@ main(int argc, char *argv[])
+ XCloseDisplay(dpy);
+ return EXIT_SUCCESS;
+ }
++
++void
++centeredmaster(Monitor *m)
++{
++ unsigned int i, n, h, mw, mx, my, oty, ety, tw;
++ Client *c;
++
++ /* count number of clients in the selected monitor */
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ if (n == 0)
++ return;
++
++ /* initialize areas */
++ mw = m->ww;
++ mx = 0;
++ my = 0;
++ tw = mw;
++
++ if (n > m->nmaster) {
++ /* go mfact box in the center if more than nmaster clients */
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ tw = m->ww - mw;
++
++ if (n - m->nmaster > 1) {
++ /* only one client */
++ mx = (m->ww - mw) / 2;
++ tw = (m->ww - mw) / 2;
++ }
++ }
++
++ oty = 0;
++ ety = 0;
++ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++ if (i < m->nmaster) {
++ /* nmaster clients are stacked vertically, in the center
++ * of the screen */
++ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
++ resize(c, m->wx + mx, m->wy + my, mw - (2*c->bw),
++ h - (2*c->bw), 0);
++ my += HEIGHT(c);
++ } else {
++ /* stack clients are stacked vertically */
++ if ((i - m->nmaster) % 2 ) {
++ h = (m->wh - ety) / ( (1 + n - i) / 2);
++ resize(c, m->wx, m->wy + ety, tw - (2*c->bw),
++ h - (2*c->bw), 0);
++ ety += HEIGHT(c);
++ } else {
++ h = (m->wh - oty) / ((1 + n - i) / 2);
++ resize(c, m->wx + mx + mw, m->wy + oty,
++ tw - (2*c->bw), h - (2*c->bw), 0);
++ oty += HEIGHT(c);
++ }
++ }
++}
++
++void
++centeredfloatingmaster(Monitor *m)
++{
++ unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx;
++ Client *c;
++
++ /* count number of clients in the selected monitor */
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ if (n == 0)
++ return;
++
++ /* initialize nmaster area */
++ if (n > m->nmaster) {
++ /* go mfact box in the center if more than nmaster clients */
++ if (m->ww > m->wh) {
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ mh = m->nmaster ? m->wh * 0.9 : 0;
++ } else {
++ mh = m->nmaster ? m->wh * m->mfact : 0;
++ mw = m->nmaster ? m->ww * 0.9 : 0;
++ }
++ mx = mxo = (m->ww - mw) / 2;
++ my = myo = (m->wh - mh) / 2;
++ } else {
++ /* go fullscreen if all clients are in the master area */
++ mh = m->wh;
++ mw = m->ww;
++ mx = mxo = 0;
++ my = myo = 0;
++ }
++
++ for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
++ if (i < m->nmaster) {
++ /* nmaster clients are stacked horizontally, in the center
++ * of the screen */
++ w = (mw + mxo - mx) / (MIN(n, m->nmaster) - i);
++ resize(c, m->wx + mx, m->wy + my, w - (2*c->bw),
++ mh - (2*c->bw), 0);
++ mx += WIDTH(c);
++ } else {
++ /* stack clients are stacked horizontally */
++ w = (m->ww - tx) / (n - i);
++ resize(c, m->wx + tx, m->wy, w - (2*c->bw),
++ m->wh - (2*c->bw), 0);
++ tx += WIDTH(c);
++ }
++}
diff --git a/patches/dwm-dragmfact-6.2.diff b/patches/dwm-dragmfact-6.2.diff
new file mode 100644
index 0000000..5ceb723
--- /dev/null
+++ b/patches/dwm-dragmfact-6.2.diff
@@ -0,0 +1,68 @@
+From 17df87822b379ce47d0aba3c36c5ef0adf4a7c3e Mon Sep 17 00:00:00 2001
+From: Miles Alan <m@milesalan.com>
+Date: Sun, 8 Dec 2019 18:15:13 -0600
+Subject: [PATCH] Mod + Right click / drag in tiling mode to resize mfact.
+ Works with multiple monitors.
+
+---
+ dwm.c | 32 +++++++++++++++++++++++---------
+ 1 file changed, 23 insertions(+), 9 deletions(-)
+
+diff --git a/dwm.c b/dwm.c
+index c15f679..e273803 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -1911,7 +1911,16 @@ resizemouse(const Arg *arg)
+ if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
+ return;
+- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
++
++ if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) {
++ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
++ } else {
++ XWarpPointer(dpy, None, root, 0, 0, 0, 0,
++ selmon->mx + (selmon->ww * selmon->mfact),
++ selmon->my + (selmon->wh / 2)
++ );
++ }
++
+ do {
+ XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
+ switch(ev.type) {
+@@ -1927,19 +1936,24 @@ resizemouse(const Arg *arg)
+
+ nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
+ nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
+- if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
+- && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
+- {
+- if (!c->isfloating && selmon->lt[selmon->sellt]->arrange
+- && (abs(nw - c->w) > snap || abs(nh - c->h) > snap))
+- togglefloating(NULL);
+- }
++
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, c->x, c->y, nw, nh, 1);
+ break;
+ }
+ } while (ev.type != ButtonRelease);
+- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
++
++ if (c->isfloating || NULL == c->mon->lt[c->mon->sellt]->arrange) {
++ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
++ } else {
++ selmon->mfact = (double) (ev.xmotion.x_root - selmon->mx) / (double) selmon->ww;
++ arrange(selmon);
++ XWarpPointer(dpy, None, root, 0, 0, 0, 0,
++ selmon->mx + (selmon->ww * selmon->mfact),
++ selmon->my + (selmon->wh / 2)
++ );
++ }
++
+ XUngrabPointer(dpy, CurrentTime);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
+--
+2.23.0
+
diff --git a/patches/dwm-movecenter-6.2.diff b/patches/dwm-movecenter-6.2.diff
new file mode 100644
index 0000000..4be852f
--- /dev/null
+++ b/patches/dwm-movecenter-6.2.diff
@@ -0,0 +1,39 @@
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..c5b14ba 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -84,6 +84,7 @@ 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_x, movecenter, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index 4465af1..292c70e 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -183,6 +183,7 @@ static void maprequest(XEvent *e);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static void movecenter(const Arg *arg);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *);
+ static void propertynotify(XEvent *e);
+@@ -1192,6 +1193,14 @@ movemouse(const Arg *arg)
+ }
+ }
+
++void
++movecenter(const Arg *arg)
++{
++ selmon->sel->x = selmon->sel->mon->mx + (selmon->sel->mon->mw - WIDTH(selmon->sel)) / 2;
++ selmon->sel->y = selmon->sel->mon->my + (selmon->sel->mon->mh - HEIGHT(selmon->sel)) / 2;
++ arrange(selmon);
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
diff --git a/patches/dwm-resizecorners-6.2.diff b/patches/dwm-resizecorners-6.2.diff
new file mode 100644
index 0000000..016351c
--- /dev/null
+++ b/patches/dwm-resizecorners-6.2.diff
@@ -0,0 +1,68 @@
+diff -r -u a/dwm.c b/dwm.c
+--- a/dwm.c 2019-02-02 07:55:28.000000000 -0500
++++ b/dwm.c 2022-01-17 22:38:33.614493243 -0500
+@@ -1291,9 +1291,14 @@
+ resizemouse(const Arg *arg)
+ {
+ int ocx, ocy, nw, nh;
++ int ocx2, ocy2, nx, ny;
+ Client *c;
+ Monitor *m;
+ XEvent ev;
++ int horizcorner, vertcorner;
++ int di;
++ unsigned int dui;
++ Window dummy;
+ Time lasttime = 0;
+
+ if (!(c = selmon->sel))
+@@ -1303,10 +1308,18 @@
+ restack(selmon);
+ ocx = c->x;
+ ocy = c->y;
++ ocx2 = c->x + c->w;
++ ocy2 = c->y + c->h;
+ if (XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurResize]->cursor, CurrentTime) != GrabSuccess)
+ return;
+- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
++ if (!XQueryPointer (dpy, c->win, &dummy, &dummy, &di, &di, &nx, &ny, &dui))
++ return;
++ horizcorner = nx < c->w / 2;
++ vertcorner = ny < c->h / 2;
++ XWarpPointer (dpy, None, c->win, 0, 0, 0, 0,
++ horizcorner ? (-c->bw) : (c->w + c->bw -1),
++ vertcorner ? (-c->bw) : (c->h + c->bw -1));
+ do {
+ XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
+ switch(ev.type) {
+@@ -1320,8 +1333,11 @@
+ continue;
+ lasttime = ev.xmotion.time;
+
+- nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
+- nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
++ nx = horizcorner ? ev.xmotion.x : c->x;
++ ny = vertcorner ? ev.xmotion.y : c->y;
++ nw = MAX(horizcorner ? (ocx2 - nx) : (ev.xmotion.x - ocx - 2 * c->bw + 1), 1);
++ nh = MAX(vertcorner ? (ocy2 - ny) : (ev.xmotion.y - ocy - 2 * c->bw + 1), 1);
++
+ if (c->mon->wx + nw >= selmon->wx && c->mon->wx + nw <= selmon->wx + selmon->ww
+ && c->mon->wy + nh >= selmon->wy && c->mon->wy + nh <= selmon->wy + selmon->wh)
+ {
+@@ -1330,11 +1346,13 @@
+ togglefloating(NULL);
+ }
+ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+- resize(c, c->x, c->y, nw, nh, 1);
++ resize(c, nx, ny, nw, nh, 1);
+ break;
+ }
+ } while (ev.type != ButtonRelease);
+- XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
++ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
++ horizcorner ? (-c->bw) : (c->w + c->bw - 1),
++ vertcorner ? (-c->bw) : (c->h + c->bw - 1));
+ XUngrabPointer(dpy, CurrentTime);
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
diff --git a/patches/dwm-swallow-6.3.diff b/patches/dwm-swallow-6.3.diff
new file mode 100644
index 0000000..47586a0
--- /dev/null
+++ b/patches/dwm-swallow-6.3.diff
@@ -0,0 +1,412 @@
+From 0cf9a007511f7dfd7dd94171b172562ebac9b6d5 Mon Sep 17 00:00:00 2001
+From: Tom Schwindl <schwindl@posteo.de>
+Date: Sat, 10 Sep 2022 12:51:09 +0200
+Subject: [PATCH] 6.3 swallow patch
+
+---
+ config.def.h | 9 +-
+ config.mk | 3 +-
+ dwm.c | 235 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 3 files changed, 237 insertions(+), 10 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 061ad662f82a..0b2b8ffd30d5 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -3,6 +3,7 @@
+ /* appearance */
+ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
++static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
+ static const char *fonts[] = { "monospace:size=10" };
+@@ -26,9 +27,11 @@ static const Rule rules[] = {
+ * WM_CLASS(STRING) = instance, class
+ * WM_NAME(STRING) = title
+ */
+- /* class instance title tags mask isfloating monitor */
+- { "Gimp", NULL, NULL, 0, 1, -1 },
+- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
++ /* class instance title tags mask isfloating isterminal noswallow monitor */
++ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
++ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
++ { "St", NULL, NULL, 0, 0, 1, 0, -1 },
++ { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
+ };
+
+ /* layout(s) */
+diff --git a/config.mk b/config.mk
+index 81c493ef4aff..52d1ebf30bec 100644
+--- a/config.mk
++++ b/config.mk
+@@ -20,10 +20,11 @@ FREETYPEINC = /usr/include/freetype2
+ # OpenBSD (uncomment)
+ #FREETYPEINC = ${X11INC}/freetype2
+ #MANPREFIX = ${PREFIX}/man
++#KVMLIB = -lkvm
+
+ # includes and libs
+ INCS = -I${X11INC} -I${FREETYPEINC}
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res ${KVMLIB}
+
+ # flags
+ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+diff --git a/dwm.c b/dwm.c
+index e5efb6a22806..e68294b6b679 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -40,6 +40,12 @@
+ #include <X11/extensions/Xinerama.h>
+ #endif /* XINERAMA */
+ #include <X11/Xft/Xft.h>
++#include <X11/Xlib-xcb.h>
++#include <xcb/res.h>
++#ifdef __OpenBSD__
++#include <sys/sysctl.h>
++#include <kvm.h>
++#endif /* __OpenBSD */
+
+ #include "drw.h"
+ #include "util.h"
+@@ -92,9 +98,11 @@ struct Client {
+ int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
+ int bw, oldbw;
+ unsigned int tags;
+- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
++ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
++ pid_t pid;
+ Client *next;
+ Client *snext;
++ Client *swallowing;
+ Monitor *mon;
+ Window win;
+ };
+@@ -138,6 +146,8 @@ typedef struct {
+ const char *title;
+ unsigned int tags;
+ int isfloating;
++ int isterminal;
++ int noswallow;
+ int monitor;
+ } Rule;
+
+@@ -235,6 +245,12 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
+ static int xerrorstart(Display *dpy, XErrorEvent *ee);
+ static void zoom(const Arg *arg);
+
++static pid_t getparentprocess(pid_t p);
++static int isdescprocess(pid_t p, pid_t c);
++static Client *swallowingclient(Window w);
++static Client *termforwin(const Client *c);
++static pid_t winpid(Window w);
++
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
+@@ -269,6 +285,8 @@ static Drw *drw;
+ static Monitor *mons, *selmon;
+ static Window root, wmcheckwin;
+
++static xcb_connection_t *xcon;
++
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
+@@ -298,6 +316,8 @@ applyrules(Client *c)
+ && (!r->class || strstr(class, r->class))
+ && (!r->instance || strstr(instance, r->instance)))
+ {
++ c->isterminal = r->isterminal;
++ c->noswallow = r->noswallow;
+ c->isfloating = r->isfloating;
+ c->tags |= r->tags;
+ for (m = mons; m && m->num != r->monitor; m = m->next);
+@@ -416,6 +436,53 @@ attachstack(Client *c)
+ c->mon->stack = c;
+ }
+
++void
++swallow(Client *p, Client *c)
++{
++
++ if (c->noswallow || c->isterminal)
++ return;
++ if (c->noswallow && !swallowfloating && c->isfloating)
++ return;
++
++ detach(c);
++ detachstack(c);
++
++ setclientstate(c, WithdrawnState);
++ XUnmapWindow(dpy, p->win);
++
++ p->swallowing = c;
++ c->mon = p->mon;
++
++ Window w = p->win;
++ p->win = c->win;
++ c->win = w;
++ updatetitle(p);
++ XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h);
++ arrange(p->mon);
++ configure(p);
++ updateclientlist();
++}
++
++void
++unswallow(Client *c)
++{
++ c->win = c->swallowing->win;
++
++ free(c->swallowing);
++ c->swallowing = NULL;
++
++ /* unfullscreen the client */
++ setfullscreen(c, 0);
++ updatetitle(c);
++ arrange(c->mon);
++ XMapWindow(dpy, c->win);
++ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
++ setclientstate(c, NormalState);
++ focus(NULL);
++ arrange(c->mon);
++}
++
+ void
+ buttonpress(XEvent *e)
+ {
+@@ -656,6 +723,9 @@ destroynotify(XEvent *e)
+
+ if ((c = wintoclient(ev->window)))
+ unmanage(c, 1);
++
++ else if ((c = swallowingclient(ev->window)))
++ unmanage(c->swallowing, 1);
+ }
+
+ void
+@@ -1022,12 +1092,13 @@ killclient(const Arg *arg)
+ void
+ manage(Window w, XWindowAttributes *wa)
+ {
+- Client *c, *t = NULL;
++ Client *c, *t = NULL, *term = NULL;
+ Window trans = None;
+ XWindowChanges wc;
+
+ c = ecalloc(1, sizeof(Client));
+ c->win = w;
++ c->pid = winpid(w);
+ /* geometry */
+ c->x = c->oldx = wa->x;
+ c->y = c->oldy = wa->y;
+@@ -1042,6 +1113,7 @@ manage(Window w, XWindowAttributes *wa)
+ } else {
+ c->mon = selmon;
+ applyrules(c);
++ term = termforwin(c);
+ }
+
+ if (c->x + WIDTH(c) > c->mon->wx + c->mon->ww)
+@@ -1076,6 +1148,8 @@ manage(Window w, XWindowAttributes *wa)
+ c->mon->sel = c;
+ arrange(c->mon);
+ XMapWindow(dpy, c->win);
++ if (term)
++ swallow(term, c);
+ focus(NULL);
+ }
+
+@@ -1763,6 +1837,20 @@ unmanage(Client *c, int destroyed)
+ Monitor *m = c->mon;
+ XWindowChanges wc;
+
++ if (c->swallowing) {
++ unswallow(c);
++ return;
++ }
++
++ Client *s = swallowingclient(c->win);
++ if (s) {
++ free(s->swallowing);
++ s->swallowing = NULL;
++ arrange(m);
++ focus(NULL);
++ return;
++ }
++
+ detach(c);
+ detachstack(c);
+ if (!destroyed) {
+@@ -1778,9 +1866,12 @@ unmanage(Client *c, int destroyed)
+ XUngrabServer(dpy);
+ }
+ free(c);
+- focus(NULL);
+- updateclientlist();
+- arrange(m);
++
++ if (!s) {
++ arrange(m);
++ focus(NULL);
++ updateclientlist();
++ }
+ }
+
+ void
+@@ -2044,6 +2135,136 @@ view(const Arg *arg)
+ arrange(selmon);
+ }
+
++pid_t
++winpid(Window w)
++{
++
++ pid_t result = 0;
++
++#ifdef __linux__
++ xcb_res_client_id_spec_t spec = {0};
++ spec.client = w;
++ spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID;
++
++ xcb_generic_error_t *e = NULL;
++ xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec);
++ xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e);
++
++ if (!r)
++ return (pid_t)0;
++
++ xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r);
++ for (; i.rem; xcb_res_client_id_value_next(&i)) {
++ spec = i.data->spec;
++ if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
++ uint32_t *t = xcb_res_client_id_value_value(i.data);
++ result = *t;
++ break;
++ }
++ }
++
++ free(r);
++
++ if (result == (pid_t)-1)
++ result = 0;
++
++#endif /* __linux__ */
++
++#ifdef __OpenBSD__
++ Atom type;
++ int format;
++ unsigned long len, bytes;
++ unsigned char *prop;
++ pid_t ret;
++
++ if (XGetWindowProperty(dpy, w, XInternAtom(dpy, "_NET_WM_PID", 0), 0, 1, False, AnyPropertyType, &type, &format, &len, &bytes, &prop) != Success || !prop)
++ return 0;
++
++ ret = *(pid_t*)prop;
++ XFree(prop);
++ result = ret;
++
++#endif /* __OpenBSD__ */
++ return result;
++}
++
++pid_t
++getparentprocess(pid_t p)
++{
++ unsigned int v = 0;
++
++#ifdef __linux__
++ FILE *f;
++ char buf[256];
++ snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
++
++ if (!(f = fopen(buf, "r")))
++ return 0;
++
++ fscanf(f, "%*u %*s %*c %u", &v);
++ fclose(f);
++#endif /* __linux__*/
++
++#ifdef __OpenBSD__
++ int n;
++ kvm_t *kd;
++ struct kinfo_proc *kp;
++
++ kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, NULL);
++ if (!kd)
++ return 0;
++
++ kp = kvm_getprocs(kd, KERN_PROC_PID, p, sizeof(*kp), &n);
++ v = kp->p_ppid;
++#endif /* __OpenBSD__ */
++
++ return (pid_t)v;
++}
++
++int
++isdescprocess(pid_t p, pid_t c)
++{
++ while (p != c && c != 0)
++ c = getparentprocess(c);
++
++ return (int)c;
++}
++
++Client *
++termforwin(const Client *w)
++{
++ Client *c;
++ Monitor *m;
++
++ if (!w->pid || w->isterminal)
++ return NULL;
++
++ for (m = mons; m; m = m->next) {
++ for (c = m->clients; c; c = c->next) {
++ if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid))
++ return c;
++ }
++ }
++
++ return NULL;
++}
++
++Client *
++swallowingclient(Window w)
++{
++ Client *c;
++ Monitor *m;
++
++ for (m = mons; m; m = m->next) {
++ for (c = m->clients; c; c = c->next) {
++ if (c->swallowing && c->swallowing->win == w)
++ return c;
++ }
++ }
++
++ return NULL;
++}
++
+ Client *
+ wintoclient(Window w)
+ {
+@@ -2133,10 +2354,12 @@ main(int argc, char *argv[])
+ fputs("warning: no locale support\n", stderr);
+ if (!(dpy = XOpenDisplay(NULL)))
+ die("dwm: cannot open display");
++ if (!(xcon = XGetXCBConnection(dpy)))
++ die("dwm: cannot get xcb connection\n");
+ checkotherwm();
+ setup();
+ #ifdef __OpenBSD__
+- if (pledge("stdio rpath proc exec", NULL) == -1)
++ if (pledge("stdio rpath proc exec ps", NULL) == -1)
+ die("pledge");
+ #endif /* __OpenBSD__ */
+ scan();
+--
+2.37.2
+
diff --git a/patches/dwm-titlecolor-20210815-ed3ab6b4.diff b/patches/dwm-titlecolor-20210815-ed3ab6b4.diff
new file mode 100644
index 0000000..f0e5b36
--- /dev/null
+++ b/patches/dwm-titlecolor-20210815-ed3ab6b4.diff
@@ -0,0 +1,47 @@
+From 45a45a0e67f3841d8c4aed2c52b57c2a7ddf2a9a Mon Sep 17 00:00:00 2001
+From: Jack Bird <jack.bird@durham.ac.uk>
+Date: Sun, 15 Aug 2021 23:15:52 +0100
+Subject: [PATCH] Updated title color patch for 7162335
+
+---
+ config.def.h | 1 +
+ dwm.c | 4 ++--
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..5b9ae00 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -16,6 +16,7 @@ static const char *colors[][3] = {
+ /* fg bg border */
+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
+ [SchemeSel] = { col_gray4, col_cyan, col_cyan },
++ [SchemeTitle] = { col_gray4, col_cyan, col_cyan },
+ };
+
+ /* tagging */
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..73d335e 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -59,7 +59,7 @@
+
+ /* enums */
+ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
+-enum { SchemeNorm, SchemeSel }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeTitle }; /* color schemes */
+ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
+ NetWMFullscreen, NetActiveWindow, NetWMWindowType,
+ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+@@ -731,7 +731,7 @@ drawbar(Monitor *m)
+
+ if ((w = m->ww - tw - x) > bh) {
+ if (m->sel) {
+- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
++ drw_setscheme(drw, scheme[m == selmon ? SchemeTitle : SchemeNorm]);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
+ if (m->sel->isfloating)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
+--
+2.32.0
+