new patches

This commit is contained in:
Maddie H 2023-02-18 22:35:43 +00:00
parent 3182afb71a
commit 1238459791
No known key found for this signature in database
GPG Key ID: 64FAA9959751687D
4 changed files with 148 additions and 4 deletions

View File

@ -36,6 +36,12 @@ static const Rule rules[] = {
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 }, { "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) */ /* layout(s) */
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ 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 nmaster = 1; /* number of clients in master area */

39
dwm.c
View File

@ -143,6 +143,15 @@ typedef struct {
int monitor; int monitor;
} Rule; } Rule;
typedef struct {
int monitor;
int layout;
float mfact;
int nmaster;
int showbar;
int topbar;
} MonitorRule;
/* function declarations */ /* function declarations */
static void applyrules(Client *c); static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@ -664,8 +673,10 @@ configurerequest(XEvent *e)
Monitor * Monitor *
createmon(void) createmon(void)
{ {
Monitor *m; Monitor *m, *mon;
unsigned int i; unsigned int i;
unsigned int mi, j;
const MonitorRule *mr;
m = ecalloc(1, sizeof(Monitor)); m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1; m->tagset[0] = m->tagset[1] = 1;
@ -673,9 +684,27 @@ createmon(void)
m->nmaster = nmaster; m->nmaster = nmaster;
m->showbar = showbar; m->showbar = showbar;
m->topbar = topbar; m->topbar = topbar;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)]; for (mi = 0, mon = mons; mon; mon = mon->next, mi++);
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); 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 = ecalloc(1, sizeof(Pertag));
m->pertag->curtag = m->pertag->prevtag = 1; m->pertag->curtag = m->pertag->prevtag = 1;
@ -1143,6 +1172,8 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c); updatewindowtype(c);
updatesizehints(c); updatesizehints(c);
updatewmhints(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); XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0); grabbuttons(c, 0);
if (!c->isfloating) if (!c->isfloating)

View File

@ -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)

View File

@ -0,0 +1,95 @@
From 4bd473cd0894e26b24294d41b70165e608b61de7 Mon Sep 17 00:00:00 2001
From: bakkeby <bakkeby@gmail.com>
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