From 12384597919b95ec46a37473a3abcfea75da6d6b Mon Sep 17 00:00:00 2001 From: Madeleine Date: Sat, 18 Feb 2023 22:35:43 +0000 Subject: [PATCH] new patches --- config.def.h | 6 ++ dwm.c | 39 +++++++- .../dwm-alwayscenter-20200625-f04cac6.diff | 12 +++ patches/dwm-monitorrules-6.2.diff | 95 +++++++++++++++++++ 4 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 patches/dwm-alwayscenter-20200625-f04cac6.diff create mode 100644 patches/dwm-monitorrules-6.2.diff diff --git a/config.def.h b/config.def.h index c474a26..53787a3 100644 --- a/config.def.h +++ b/config.def.h @@ -36,6 +36,12 @@ static const Rule rules[] = { { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, }; +static const MonitorRule monrules[] = { + /* monitor layout mfact nmaster showbar topbar */ + { 1, 2, -1, -1, -1, -1 }, // use a different layout for the second monitor + { -1, 0, -1, -1, -1, -1 }, // default +}; + /* 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 */ diff --git a/dwm.c b/dwm.c index e123a4f..c86a90a 100644 --- a/dwm.c +++ b/dwm.c @@ -143,6 +143,15 @@ typedef struct { int monitor; } Rule; +typedef struct { + int monitor; + int layout; + float mfact; + int nmaster; + int showbar; + int topbar; +} MonitorRule; + /* function declarations */ static void applyrules(Client *c); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); @@ -664,8 +673,10 @@ configurerequest(XEvent *e) Monitor * createmon(void) { - Monitor *m; + Monitor *m, *mon; unsigned int i; + unsigned int mi, j; + const MonitorRule *mr; m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; @@ -673,9 +684,27 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; - m->lt[0] = &layouts[0]; - m->lt[1] = &layouts[1 % LENGTH(layouts)]; - strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + + for (mi = 0, mon = mons; mon; mon = mon->next, mi++); + for (j = 0; j < LENGTH(monrules); j++) { + mr = &monrules[j]; + if ((mr->monitor == -1 || mr->monitor == mi)) { + m->lt[0] = &layouts[mr->layout]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[mr->layout].symbol, sizeof m->ltsymbol); + + if (mr->mfact > -1) + m->mfact = mr->mfact; + if (mr->nmaster > -1) + m->nmaster = mr->nmaster; + if (mr->showbar > -1) + m->showbar = mr->showbar; + if (mr->topbar > -1) + m->topbar = mr->topbar; + break; + } + } + m->pertag = ecalloc(1, sizeof(Pertag)); m->pertag->curtag = m->pertag->prevtag = 1; @@ -1143,6 +1172,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-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-monitorrules-6.2.diff b/patches/dwm-monitorrules-6.2.diff new file mode 100644 index 0000000..e0e00b2 --- /dev/null +++ b/patches/dwm-monitorrules-6.2.diff @@ -0,0 +1,95 @@ +From 4bd473cd0894e26b24294d41b70165e608b61de7 Mon Sep 17 00:00:00 2001 +From: bakkeby +Date: Sun, 26 Apr 2020 10:49:08 +0200 +Subject: [PATCH] Monitor rules patch + +This patch allows the user to define layout, mfact, nmaster, showbar, +and topbar settings on a per monitor basis. An example use case could +be to have a layout with a horizontal split for a secondary vertical +monitor. +--- + config.def.h | 6 ++++++ + dwm.c | 36 ++++++++++++++++++++++++++++++++---- + 2 files changed, 38 insertions(+), 4 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..b81f377 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -31,6 +31,12 @@ static const Rule rules[] = { + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + }; + ++static const MonitorRule monrules[] = { ++ /* monitor layout mfact nmaster showbar topbar */ ++ { 1, 2, -1, -1, -1, -1 }, // use a different layout for the second monitor ++ { -1, 0, -1, -1, -1, -1 }, // default ++}; ++ + /* 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 */ +diff --git a/dwm.c b/dwm.c +index 4465af1..0ad5375 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -141,6 +141,15 @@ typedef struct { + int monitor; + } Rule; + ++typedef struct { ++ int monitor; ++ int layout; ++ float mfact; ++ int nmaster; ++ int showbar; ++ int topbar; ++} MonitorRule; ++ + /* function declarations */ + static void applyrules(Client *c); + static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); +@@ -630,7 +639,9 @@ configurerequest(XEvent *e) + Monitor * + createmon(void) + { +- Monitor *m; ++ Monitor *m, *mon; ++ unsigned int mi, j; ++ const MonitorRule *mr; + + m = ecalloc(1, sizeof(Monitor)); + m->tagset[0] = m->tagset[1] = 1; +@@ -638,9 +649,26 @@ createmon(void) + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; +- m->lt[0] = &layouts[0]; +- m->lt[1] = &layouts[1 % LENGTH(layouts)]; +- strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); ++ ++ for (mi = 0, mon = mons; mon; mon = mon->next, mi++); ++ for (j = 0; j < LENGTH(monrules); j++) { ++ mr = &monrules[j]; ++ if ((mr->monitor == -1 || mr->monitor == mi)) { ++ m->lt[0] = &layouts[mr->layout]; ++ m->lt[1] = &layouts[1 % LENGTH(layouts)]; ++ strncpy(m->ltsymbol, layouts[mr->layout].symbol, sizeof m->ltsymbol); ++ ++ if (mr->mfact > -1) ++ m->mfact = mr->mfact; ++ if (mr->nmaster > -1) ++ m->nmaster = mr->nmaster; ++ if (mr->showbar > -1) ++ m->showbar = mr->showbar; ++ if (mr->topbar > -1) ++ m->topbar = mr->topbar; ++ break; ++ } ++ } + return m; + } + +-- +2.19.1 +