diff options
author | Philip Wittamore <philip@wittamore.com> | 2025-05-31 23:55:39 +0200 |
---|---|---|
committer | Philip Wittamore <philip@wittamore.com> | 2025-05-31 23:55:39 +0200 |
commit | 5d272e82d7eeb5f3850b8487cec5612717c44763 (patch) | |
tree | 8bb6fb92d9be87edf712157ed56c77a1776061e1 /patches | |
parent | 5e2e44482ce3e05be0d030a8defac1dd281840a4 (diff) | |
download | dwm-5d272e82d7eeb5f3850b8487cec5612717c44763.tar.gz dwm-5d272e82d7eeb5f3850b8487cec5612717c44763.tar.bz2 dwm-5d272e82d7eeb5f3850b8487cec5612717c44763.zip |
update
Diffstat (limited to 'patches')
-rw-r--r-- | patches/dwm-adjacenttag-6.2.diff | 126 | ||||
-rw-r--r-- | patches/dwm-attachaside-6.4.diff | 92 | ||||
-rw-r--r-- | patches/dwm-deck-6.2.diff | 77 | ||||
-rw-r--r-- | patches/dwm-hide_vacant_tags-6.4.diff | 48 | ||||
-rw-r--r-- | patches/dwm-preserveonrestart-6.3.diff | 118 | ||||
-rw-r--r-- | patches/dwm-removeborder-20220626-d3f93c7.diff | 31 | ||||
-rw-r--r-- | patches/dwm-rotatestack-20161021-ab9571b.diff | 102 | ||||
-rw-r--r-- | patches/dwm-swallow-6.3.diff | 412 | ||||
-rw-r--r-- | patches/dwm-xrdb-6.4.diff | 203 |
9 files changed, 1209 insertions, 0 deletions
diff --git a/patches/dwm-adjacenttag-6.2.diff b/patches/dwm-adjacenttag-6.2.diff new file mode 100644 index 0000000..6121f65 --- /dev/null +++ b/patches/dwm-adjacenttag-6.2.diff @@ -0,0 +1,126 @@ +diff -up a/config.def.h b/config.def.h +--- a/config.def.h 2021-10-02 13:57:18.011307099 +0100 ++++ b/config.def.h 2021-10-02 13:58:07.812080253 +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 13:57:18.011307099 +0100 ++++ b/dwm.c 2021-10-02 14:21:17.063622953 +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,13 @@ movemouse(const Arg *arg) + } + } + ++unsigned int ++nexttag(void) ++{ ++ unsigned int seltag = selmon->tagset[selmon->seltags]; ++ return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1; ++} ++ + Client * + nexttiled(Client *c) + { +@@ -1208,6 +1221,13 @@ pop(Client *c) + arrange(c->mon); + } + ++unsigned int ++prevtag(void) ++{ ++ unsigned int seltag = selmon->tagset[selmon->seltags]; ++ return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1; ++} ++ + void + propertynotify(XEvent *e) + { +@@ -1671,6 +1691,32 @@ tagmon(const Arg *arg) + } + + void ++tagtonext(const Arg *arg) ++{ ++ unsigned int tmp; ++ ++ if (selmon->sel == NULL) ++ return; ++ ++ tmp = nexttag(); ++ tag(&(const Arg){.ui = tmp }); ++ view(&(const Arg){.ui = tmp }); ++} ++ ++void ++tagtoprev(const Arg *arg) ++{ ++ unsigned int tmp; ++ ++ if (selmon->sel == NULL) ++ return; ++ ++ tmp = prevtag(); ++ tag(&(const Arg){.ui = tmp }); ++ view(&(const Arg){.ui = tmp }); ++} ++ ++void + tile(Monitor *m) + { + unsigned int i, n, h, mw, my, ty; +@@ -2044,6 +2090,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-attachaside-6.4.diff b/patches/dwm-attachaside-6.4.diff new file mode 100644 index 0000000..17be6b5 --- /dev/null +++ b/patches/dwm-attachaside-6.4.diff @@ -0,0 +1,92 @@ +diff --git a/dwm.c b/dwm.c +index f1d86b2..8b04e0b 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -49,7 +49,8 @@ + #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) + #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ + * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) +-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) ++#define ISVISIBLEONTAG(C, T) ((C->tags & T)) ++#define ISVISIBLE(C) ISVISIBLEONTAG(C, 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) +@@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac + static void arrange(Monitor *m); + static void arrangemon(Monitor *m); + static void attach(Client *c); ++static void attachaside(Client *c); + static void attachstack(Client *c); + static void buttonpress(XEvent *e); + static void checkotherwm(void); +@@ -184,6 +186,7 @@ static void maprequest(XEvent *e); + static void monocle(Monitor *m); + static void motionnotify(XEvent *e); + static void movemouse(const Arg *arg); ++static Client *nexttagged(Client *c); + static Client *nexttiled(Client *c); + static void pop(Client *c); + static void propertynotify(XEvent *e); +@@ -408,6 +411,17 @@ attach(Client *c) + c->mon->clients = c; + } + ++void ++attachaside(Client *c) { ++ Client *at = nexttagged(c); ++ if(!at) { ++ attach(c); ++ return; ++ } ++ c->next = at->next; ++ at->next = c; ++} ++ + void + attachstack(Client *c) + { +@@ -1074,7 +1088,7 @@ manage(Window w, XWindowAttributes *wa) + c->isfloating = c->oldstate = trans != None || c->isfixed; + if (c->isfloating) + XRaiseWindow(dpy, c->win); +- attach(c); ++ attachaside(c); + attachstack(c); + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); +@@ -1202,6 +1216,16 @@ movemouse(const Arg *arg) + } + } + ++Client * ++nexttagged(Client *c) { ++ Client *walked = c->mon->clients; ++ for(; ++ walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags)); ++ walked = walked->next ++ ); ++ return walked; ++} ++ + Client * + nexttiled(Client *c) + { +@@ -1427,7 +1451,7 @@ sendmon(Client *c, Monitor *m) + detachstack(c); + c->mon = m; + c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ +- attach(c); ++ attachaside(c); + attachstack(c); + focus(NULL); + arrange(NULL); +@@ -1915,7 +1939,7 @@ updategeom(void) + m->clients = c->next; + detachstack(c); + c->mon = mons; +- attach(c); ++ attachaside(c); + attachstack(c); + } + if (m == selmon) diff --git a/patches/dwm-deck-6.2.diff b/patches/dwm-deck-6.2.diff new file mode 100644 index 0000000..b5afed7 --- /dev/null +++ b/patches/dwm-deck-6.2.diff @@ -0,0 +1,77 @@ +From a071b060a1b9b94bcb167b988cf7774ceb870aad Mon Sep 17 00:00:00 2001 +From: Jack Bird <jack.bird@durham.ac.uk> +Date: Mon, 2 Aug 2021 18:44:05 +0100 +Subject: [PATCH] deck patch works with 6.2 + +--- + config.def.h | 2 ++ + dwm.c | 26 ++++++++++++++++++++++++++ + 2 files changed, 28 insertions(+) + +diff --git a/config.def.h b/config.def.h +index a2ac963..d865e18 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -42,6 +42,7 @@ static const Layout layouts[] = { + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "[D]", deck }, + }; + + /* key definitions */ +@@ -77,6 +78,7 @@ 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_r, setlayout, {.v = &layouts[3]} }, + { 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 5e4d494..c67ff91 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -157,6 +157,7 @@ static void configure(Client *c); + static void configurenotify(XEvent *e); + static void configurerequest(XEvent *e); + static Monitor *createmon(void); ++static void deck(Monitor *m); + static void destroynotify(XEvent *e); + static void detach(Client *c); + static void detachstack(Client *c); +@@ -655,6 +656,31 @@ destroynotify(XEvent *e) + unmanage(c, 1); + } + ++void ++deck(Monitor *m) { ++ unsigned int i, n, h, mw, my; ++ Client *c; ++ ++ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); ++ if(n == 0) ++ return; ++ ++ if(n > m->nmaster) { ++ mw = m->nmaster ? m->ww * m->mfact : 0; ++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster); ++ } ++ else ++ mw = m->ww; ++ for(i = my = 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), False); ++ my += HEIGHT(c); ++ } ++ else ++ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False); ++} ++ + void + detach(Client *c) + { +-- +2.32.0 + diff --git a/patches/dwm-hide_vacant_tags-6.4.diff b/patches/dwm-hide_vacant_tags-6.4.diff new file mode 100644 index 0000000..42d9c05 --- /dev/null +++ b/patches/dwm-hide_vacant_tags-6.4.diff @@ -0,0 +1,48 @@ +:100644 100644 f1d86b2 0000000 M dwm.c + +diff --git a/dwm.c b/dwm.c +index f1d86b2..d41cc14 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -433,9 +433,15 @@ buttonpress(XEvent *e) + } + if (ev->window == selmon->barwin) { + i = x = 0; +- do ++ unsigned int occ = 0; ++ for(c = m->clients; c; c=c->next) ++ occ |= c->tags == TAGMASK ? 0 : c->tags; ++ do { ++ /* Do not reserve space for vacant tags */ ++ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) ++ continue; + x += TEXTW(tags[i]); +- while (ev->x >= x && ++i < LENGTH(tags)); ++ } while (ev->x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + click = ClkTagBar; + arg.ui = 1 << i; +@@ -715,19 +721,18 @@ drawbar(Monitor *m) + } + + for (c = m->clients; c; c = c->next) { +- occ |= c->tags; ++ occ |= c->tags == TAGMASK ? 0 : c->tags; + if (c->isurgent) + urg |= c->tags; + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { ++ /* Do not draw vacant tags */ ++ if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) ++ continue; + 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); + x += w; + } + w = TEXTW(m->ltsymbol); diff --git a/patches/dwm-preserveonrestart-6.3.diff b/patches/dwm-preserveonrestart-6.3.diff new file mode 100644 index 0000000..079cf05 --- /dev/null +++ b/patches/dwm-preserveonrestart-6.3.diff @@ -0,0 +1,118 @@ +From 713fa8650f5a20006451ebcccf57a4512e83bae8 Mon Sep 17 00:00:00 2001 +From: Arda Atci <arda@phytech.io> +Date: Wed, 18 May 2022 17:23:16 +0300 +Subject: [PATCH] preserve clients on old tags when renewing dwm + +By default, when dwm is recompiled-restarted all clients will +lose it's current tag and collapse to first tag. This patch preserves +clients on old tags, however note that layout order is not preserved. + +--- + dwm.c | 38 +++++++++++++++++++++++++++++++++++++- + 1 file changed, 37 insertions(+), 1 deletion(-) + +diff --git a/dwm.c b/dwm.c +index a96f33c..a12e0bd 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -62,7 +62,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ + enum { SchemeNorm, SchemeSel }; /* color schemes */ + enum { NetSupported, NetWMName, NetWMState, NetWMCheck, + NetWMFullscreen, NetActiveWindow, NetWMWindowType, +- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ ++ NetWMWindowTypeDialog, NetClientList, NetClientInfo, NetLast }; /* EWMH atoms */ + enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ + enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, + ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ +@@ -198,6 +198,7 @@ static void scan(void); + static int sendevent(Client *c, Atom proto); + static void sendmon(Client *c, Monitor *m); + static void setclientstate(Client *c, long state); ++static void setclienttagprop(Client *c); + static void setfocus(Client *c); + static void setfullscreen(Client *c, int fullscreen); + static void setlayout(const Arg *arg); +@@ -1060,6 +1061,26 @@ manage(Window w, XWindowAttributes *wa) + updatewindowtype(c); + updatesizehints(c); + updatewmhints(c); ++ { ++ int format; ++ unsigned long *data, n, extra; ++ Monitor *m; ++ Atom atom; ++ if (XGetWindowProperty(dpy, c->win, netatom[NetClientInfo], 0L, 2L, False, XA_CARDINAL, ++ &atom, &format, &n, &extra, (unsigned char **)&data) == Success && n == 2) { ++ c->tags = *data; ++ for (m = mons; m; m = m->next) { ++ if (m->num == *(data+1)) { ++ c->mon = m; ++ break; ++ } ++ } ++ } ++ if (n > 0) ++ XFree(data); ++ } ++ setclienttagprop(c); ++ + XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); + grabbuttons(c, 0); + if (!c->isfloating) +@@ -1423,6 +1444,7 @@ sendmon(Client *c, Monitor *m) + c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ + attach(c); + attachstack(c); ++ setclienttagprop(c); + focus(NULL); + arrange(NULL); + } +@@ -1566,6 +1588,7 @@ setup(void) + netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); + netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); ++ netatom[NetClientInfo] = XInternAtom(dpy, "_NET_CLIENT_INFO", False); + /* init cursors */ + cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); + cursor[CurResize] = drw_cur_create(drw, XC_sizing); +@@ -1589,6 +1612,7 @@ setup(void) + XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, + PropModeReplace, (unsigned char *) netatom, NetLast); + XDeleteProperty(dpy, root, netatom[NetClientList]); ++ XDeleteProperty(dpy, root, netatom[NetClientInfo]); + /* select events */ + wa.cursor = cursor[CurNormal]->cursor; + wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask +@@ -1656,11 +1680,22 @@ spawn(const Arg *arg) + } + } + ++void ++setclienttagprop(Client *c) ++{ ++ long data[] = { (long) c->tags, (long) c->mon->num }; ++ XChangeProperty(dpy, c->win, netatom[NetClientInfo], XA_CARDINAL, 32, ++ PropModeReplace, (unsigned char *) data, 2); ++} ++ + void + tag(const Arg *arg) + { ++ Client *c; + if (selmon->sel && arg->ui & TAGMASK) { ++ c = selmon->sel; + selmon->sel->tags = arg->ui & TAGMASK; ++ setclienttagprop(c); + focus(NULL); + arrange(selmon); + } +@@ -1735,6 +1770,7 @@ toggletag(const Arg *arg) + newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); + if (newtags) { + selmon->sel->tags = newtags; ++ setclienttagprop(selmon->sel); + focus(NULL); + arrange(selmon); + } +-- +2.36.1 diff --git a/patches/dwm-removeborder-20220626-d3f93c7.diff b/patches/dwm-removeborder-20220626-d3f93c7.diff new file mode 100644 index 0000000..9193a77 --- /dev/null +++ b/patches/dwm-removeborder-20220626-d3f93c7.diff @@ -0,0 +1,31 @@ +diff --git a/dwm.c b/dwm.c +index 5646a5c..27e29df 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -1283,12 +1283,26 @@ void + resizeclient(Client *c, int x, int y, int w, int h) + { + XWindowChanges wc; ++ unsigned int n; ++ 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; ++ ++ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++); ++ ++ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) { ++ } else { ++ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) { ++ wc.border_width = 0; ++ c->w = wc.width += c->bw * 2; ++ c->h = wc.height += c->bw * 2; ++ } ++ } ++ + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); + configure(c); + XSync(dpy, False); diff --git a/patches/dwm-rotatestack-20161021-ab9571b.diff b/patches/dwm-rotatestack-20161021-ab9571b.diff new file mode 100644 index 0000000..ed74c6d --- /dev/null +++ b/patches/dwm-rotatestack-20161021-ab9571b.diff @@ -0,0 +1,102 @@ +diff --git a/config.def.h b/config.def.h +index fd77a07..09737d7 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -64,6 +64,8 @@ static Key keys[] = { + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_b, togglebar, {0} }, ++ { MODKEY|ShiftMask, XK_j, rotatestack, {.i = +1 } }, ++ { MODKEY|ShiftMask, XK_k, rotatestack, {.i = -1 } }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, +diff --git a/dwm.c b/dwm.c +index 421bf27..1ec8b10 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -165,6 +165,8 @@ static void detachstack(Client *c); + static Monitor *dirtomon(int dir); + static void drawbar(Monitor *m); + static void drawbars(void); ++static void enqueue(Client *c); ++static void enqueuestack(Client *c); + static void enternotify(XEvent *e); + static void expose(XEvent *e); + static void focus(Client *c); +@@ -194,6 +196,7 @@ 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); + static void restack(Monitor *m); ++static void rotatestack(const Arg *arg); + static void run(void); + static void scan(void); + static int sendevent(Client *c, Atom proto); +@@ -765,6 +768,28 @@ drawbars(void) + } + + void ++enqueue(Client *c) ++{ ++ Client *l; ++ for (l = c->mon->clients; l && l->next; l = l->next); ++ if (l) { ++ l->next = c; ++ c->next = NULL; ++ } ++} ++ ++void ++enqueuestack(Client *c) ++{ ++ Client *l; ++ for (l = c->mon->stack; l && l->snext; l = l->snext); ++ if (l) { ++ l->snext = c; ++ c->snext = NULL; ++ } ++} ++ ++void + enternotify(XEvent *e) + { + Client *c; +@@ -1390,6 +1415,38 @@ restack(Monitor *m) + } + + void ++rotatestack(const Arg *arg) ++{ ++ Client *c = NULL, *f; ++ ++ if (!selmon->sel) ++ return; ++ f = selmon->sel; ++ if (arg->i > 0) { ++ for (c = nexttiled(selmon->clients); c && nexttiled(c->next); c = nexttiled(c->next)); ++ if (c){ ++ detach(c); ++ attach(c); ++ detachstack(c); ++ attachstack(c); ++ } ++ } else { ++ if ((c = nexttiled(selmon->clients))){ ++ detach(c); ++ enqueue(c); ++ detachstack(c); ++ enqueuestack(c); ++ } ++ } ++ if (c){ ++ arrange(selmon); ++ //unfocus(f, 1); ++ focus(f); ++ restack(selmon); ++ } ++} ++ ++void + run(void) + { + XEvent ev; 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-xrdb-6.4.diff b/patches/dwm-xrdb-6.4.diff new file mode 100644 index 0000000..929b4e6 --- /dev/null +++ b/patches/dwm-xrdb-6.4.diff @@ -0,0 +1,203 @@ +From e7c65d2ce902a19a20daa751b42f8ba0209fdb61 Mon Sep 17 00:00:00 2001 +From: NekoCWD <nekodevelopper@gmail.com> +Date: Sun, 22 Jan 2023 23:42:57 +0300 +Subject: [PATCH] [dwm] xrdb update 6.4 + +--- + config.def.h | 22 ++++++++++--------- + drw.c | 2 +- + drw.h | 2 +- + dwm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 76 insertions(+), 12 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 061ad66..686b947 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -7,15 +7,16 @@ 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" }; + static const char dmenufont[] = "monospace:size=10"; +-static const char col_gray1[] = "#222222"; +-static const char col_gray2[] = "#444444"; +-static const char col_gray3[] = "#bbbbbb"; +-static const char col_gray4[] = "#eeeeee"; +-static const char col_cyan[] = "#005577"; +-static const char *colors[][3] = { +- /* fg bg border */ +- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, +- [SchemeSel] = { col_gray4, col_cyan, col_cyan }, ++static char normbgcolor[] = "#222222"; ++static char normbordercolor[] = "#444444"; ++static char normfgcolor[] = "#bbbbbb"; ++static char selfgcolor[] = "#eeeeee"; ++static char selbordercolor[] = "#005577"; ++static char selbgcolor[] = "#005577"; ++static char *colors[][3] = { ++ /* fg bg border */ ++ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, ++ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, + }; + + /* tagging */ +@@ -56,7 +57,7 @@ static const Layout layouts[] = { + #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + + /* commands */ +-static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; ++static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL }; + static const char *termcmd[] = { "st", NULL }; + + static const Key keys[] = { +@@ -84,6 +85,7 @@ static const Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_F5, xrdb, {.v = NULL } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff --git a/drw.c b/drw.c +index a58a2b4..f8a82f5 100644 +--- a/drw.c ++++ b/drw.c +@@ -195,7 +195,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname) + /* Wrapper to create color schemes. The caller has to call free(3) on the + * returned color scheme when done using it. */ + Clr * +-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) ++drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount) + { + size_t i; + Clr *ret; +diff --git a/drw.h b/drw.h +index 6471431..bdbf950 100644 +--- a/drw.h ++++ b/drw.h +@@ -40,7 +40,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in + + /* Colorscheme abstraction */ + void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); +-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); ++Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount); + + /* Cursor abstraction */ + Cur *drw_cur_create(Drw *drw, int shape); +diff --git a/dwm.c b/dwm.c +index e5efb6a..3fe76be 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -35,6 +35,7 @@ + #include <X11/Xatom.h> + #include <X11/Xlib.h> + #include <X11/Xproto.h> ++#include <X11/Xresource.h> + #include <X11/Xutil.h> + #ifdef XINERAMA + #include <X11/extensions/Xinerama.h> +@@ -56,6 +57,21 @@ + #define HEIGHT(X) ((X)->h + 2 * (X)->bw) + #define TAGMASK ((1 << LENGTH(tags)) - 1) + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) ++#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \ ++ if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \ ++ int i = 1; \ ++ for (; i <= 6; i++) { \ ++ if (value.addr[i] < 48) break; \ ++ if (value.addr[i] > 57 && value.addr[i] < 65) break; \ ++ if (value.addr[i] > 70 && value.addr[i] < 97) break; \ ++ if (value.addr[i] > 102) break; \ ++ } \ ++ if (i == 7) { \ ++ strncpy(V, value.addr, 7); \ ++ V[7] = '\0'; \ ++ } \ ++ } \ ++ } + + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ +@@ -178,6 +194,7 @@ static void grabkeys(void); + static void incnmaster(const Arg *arg); + static void keypress(XEvent *e); + static void killclient(const Arg *arg); ++static void loadxrdb(void); + static void manage(Window w, XWindowAttributes *wa); + static void mappingnotify(XEvent *e); + static void maprequest(XEvent *e); +@@ -233,6 +250,7 @@ static Monitor *wintomon(Window w); + static int xerror(Display *dpy, XErrorEvent *ee); + static int xerrordummy(Display *dpy, XErrorEvent *ee); + static int xerrorstart(Display *dpy, XErrorEvent *ee); ++static void xrdb(const Arg *arg); + static void zoom(const Arg *arg); + + /* variables */ +@@ -1019,6 +1037,37 @@ killclient(const Arg *arg) + } + } + ++void ++loadxrdb() ++{ ++ Display *display; ++ char * resm; ++ XrmDatabase xrdb; ++ char *type; ++ XrmValue value; ++ ++ display = XOpenDisplay(NULL); ++ ++ if (display != NULL) { ++ resm = XResourceManagerString(display); ++ ++ if (resm != NULL) { ++ xrdb = XrmGetStringDatabase(resm); ++ ++ if (xrdb != NULL) { ++ XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor); ++ XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor); ++ XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor); ++ XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); ++ XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); ++ XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); ++ } ++ } ++ } ++ ++ XCloseDisplay(display); ++} ++ + void + manage(Window w, XWindowAttributes *wa) + { +@@ -2110,6 +2159,17 @@ xerrorstart(Display *dpy, XErrorEvent *ee) + return -1; + } + ++void ++xrdb(const Arg *arg) ++{ ++ loadxrdb(); ++ int i; ++ for (i = 0; i < LENGTH(colors); i++) ++ scheme[i] = drw_scm_create(drw, colors[i], 3); ++ focus(NULL); ++ arrange(NULL); ++} ++ + void + zoom(const Arg *arg) + { +@@ -2134,6 +2194,8 @@ main(int argc, char *argv[]) + if (!(dpy = XOpenDisplay(NULL))) + die("dwm: cannot open display"); + checkotherwm(); ++ XrmInitialize(); ++ loadxrdb(); + setup(); + #ifdef __OpenBSD__ + if (pledge("stdio rpath proc exec", NULL) == -1) +-- +2.38.2 + |