summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2022-03-26 14:07:23 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2022-03-26 14:07:23 -0400
commit447a628611c454a70bede9ef6bfe4ab833bdedf3 (patch)
tree4d6ea34c5ade6f78ec0fc9afc16ed0f8b6b23748
parent21f0ddbe1c5dabde7a81a44d10d8c231a27fb72e (diff)
Add defaultlayoutpermonitor patch
TODO: make sure the bugfix at dwm:301 works when daily driving
-rw-r--r--config.def.h5
-rw-r--r--dwm.c18
-rw-r--r--patch/defaultlayoutpermonitor.diff58
3 files changed, 81 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index 6c33198..48aac9c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -39,6 +39,11 @@ 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 lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+static const int lpm[] = {
+ /* Index of preferred layout], if LENGTH(lpm)<#monitors -> default layout */
+ 0, 4
+};
+
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
diff --git a/dwm.c b/dwm.c
index eae19b0..4166013 100644
--- a/dwm.c
+++ b/dwm.c
@@ -144,6 +144,7 @@ typedef struct {
} Rule;
/* function declarations */
+static void applydefaultlayouts();
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
static void arrange(Monitor *m);
@@ -290,6 +291,22 @@ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
/* function implementations */
void
+applydefaultlayouts()
+{
+ Monitor *m;
+ int i = 0;
+ for (m = mons; m; m = m->next) {
+ if (i < LENGTH(lpm)) {
+ m->lt[0] = &layouts[lpm[i]];
+ m->lt[1] = &layouts[(lpm[i] + 1)/ LENGTH(layouts)];
+ /* m->lt[1] = &layouts[(lpm[i] + 1)/ % LENGTH(layouts)]; */
+ strncpy(m->ltsymbol, layouts[i].symbol, sizeof m->ltsymbol);
+ }
+ i++;
+ }
+}
+
+void
applyrules(Client *c)
{
const char *class, *instance;
@@ -2096,6 +2113,7 @@ updategeom(void)
cleanupmon(m);
}
}
+ applydefaultlayouts();
free(unique);
} else
#endif /* XINERAMA */
diff --git a/patch/defaultlayoutpermonitor.diff b/patch/defaultlayoutpermonitor.diff
new file mode 100644
index 0000000..ba8e4f6
--- /dev/null
+++ b/patch/defaultlayoutpermonitor.diff
@@ -0,0 +1,58 @@
+diff --git a/config.def.h b/config.def.h
+index a2ac963..7c87de8 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -37,6 +37,11 @@ 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 lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+
++static const int lpm[] = {
++ /* Index of preferred layout], if LENGTH(lpm)<#monitors -> default layout */
++ 0, 1
++};
++
+ static const Layout layouts[] = {
+ /* symbol arrange function */
+ { "[]=", tile }, /* first entry is default */
+diff --git a/dwm.c b/dwm.c
+index a96f33c..64cec29 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -142,6 +142,7 @@ typedef struct {
+ } Rule;
+
+ /* function declarations */
++static void applydefaultlayouts();
+ static void applyrules(Client *c);
+ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
+ static void arrange(Monitor *m);
+@@ -276,6 +277,21 @@ static Window root, wmcheckwin;
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+ /* function implementations */
++void
++applydefaultlayouts()
++{
++ Monitor *m;
++ int i = 0;
++ for (m = mons; m; m = m->next) {
++ if (i < LENGTH(lpm)) {
++ m->lt[0] = &layouts[lpm[i]];
++ m->lt[1] = &layouts[(lpm[i] + 1)/ % LENGTH(layouts)];
++ strncpy(m->ltsymbol, layouts[i].symbol, sizeof m->ltsymbol);
++ }
++ i++;
++ }
++}
++
+ void
+ applyrules(Client *c)
+ {
+@@ -1911,6 +1927,7 @@ updategeom(void)
+ cleanupmon(m);
+ }
+ }
++ applydefaultlayouts();
+ free(unique);
+ } else
+ #endif /* XINERAMA */