From 13ea4e72340b8c67042ff827c995d7258509361b Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Fri, 26 Jan 2024 18:56:49 -0500 Subject: Implement defaultlayoutpermonitor --- config.def.h | 5 +++++ dwm.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/config.def.h b/config.def.h index 9c2b2c5..804752e 100644 --- a/config.def.h +++ b/config.def.h @@ -45,6 +45,11 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int mainmon = 0; /* xsetroot will only change the bar on this monitor */ +static const int lpm[] = { + /* Index of preferred layout], if LENGTH(lpm)<#monitors -> default layout */ + 0, 5 +}; + static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ diff --git a/dwm.c b/dwm.c index ff5322a..f8962e0 100644 --- a/dwm.c +++ b/dwm.c @@ -143,6 +143,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); @@ -295,6 +296,21 @@ static Colormap cmap; 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) { @@ -2119,6 +2135,7 @@ updategeom(void) selmon = mons; cleanupmon(m); } + applydefaultlayouts(); free(unique); } else #endif /* XINERAMA */ -- cgit v1.2.3