summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2023-02-10 11:34:44 +0100
committertslil clingman <tslil@posteo.de>2023-02-10 11:34:44 +0100
commit2915c2984e81251256a9dbe6eb64c8ff950279d0 (patch)
tree5593cb863a8c112ae7147132326f3df21423a16f
parent67b505107e8c8075b409bdc7a7a8a0158caf4aa6 (diff)
[dwm] rstack hack, bstack{,horiz}, default per monitor
-rw-r--r--dwm-6.2/config.def.h9
-rw-r--r--dwm-6.2/config.h18
-rw-r--r--dwm-6.2/defaultlayoutpermonitor.diff58
-rw-r--r--dwm-6.2/dwm.c89
4 files changed, 167 insertions, 7 deletions
diff --git a/dwm-6.2/config.def.h b/dwm-6.2/config.def.h
index 47f0981..f736342 100644
--- a/dwm-6.2/config.def.h
+++ b/dwm-6.2/config.def.h
@@ -41,11 +41,18 @@ 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 resizehints = 1; /* 1 means respect size hints in tiled resizals */
+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 */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "TTT", bstack },
+ { "===", bstackhoriz },
};
/* key definitions */
@@ -81,6 +88,8 @@ 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_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
diff --git a/dwm-6.2/config.h b/dwm-6.2/config.h
index d2baa43..f86a868 100644
--- a/dwm-6.2/config.h
+++ b/dwm-6.2/config.h
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
/* appearance */
-static const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int borderpx = 2; /* border pixel of windows */
static const unsigned int gappx = 3; /* gaps between windows */
static const unsigned int snap = 16; /* snap pixel */
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
@@ -10,7 +10,7 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display s
static const int showsystray = 1; /* 0 means no systray */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 0; /* 0 means bottom bar */
-static const char *fonts[] = { "Terminus:size=12" };
+static const char *fonts[] = { "BmPlus IBM VGA 9x16:size=12" };
static const char col_gray1[] = "#000000";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
@@ -39,10 +39,17 @@ 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 resizehints = 1; /* 1 means respect size hints in tiled resizals */
+static const int lpm[] = {
+ /* Index of preferred layout], if LENGTH(lpm)<#monitors -> default layout */
+ 2, 0
+};
+
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "[M]", monocle },
+ { "===", bstackhoriz },
+ { "TTT", bstack },
{ "><>", NULL }, /* no layout function means floating behavior */
};
@@ -117,7 +124,9 @@ static Key keys[] = {
{ MODKEY, XK_s, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_r, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_a, setlayout, {.v = &layouts[2]} },
- { MODKEY|ShiftMask, XK_r, togglefloating, {0} },
+ { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[3]} },
+ { MODKEY|ShiftMask, XK_r, setlayout, {.v = &layouts[4]} },
+ { MODKEY|ShiftMask, XK_a, togglefloating, {0} },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_b, focusmon, {.i = +1 } },
@@ -146,8 +155,7 @@ static Button buttons[] = {
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
- { ClkClientWin, MODKEY|ShiftMask, Button1, resizemouse, {0} },
- { ClkClientWin, MODKEY, Button2, resizemouse, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
diff --git a/dwm-6.2/defaultlayoutpermonitor.diff b/dwm-6.2/defaultlayoutpermonitor.diff
new file mode 100644
index 0000000..ba8e4f6
--- /dev/null
+++ b/dwm-6.2/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 */
diff --git a/dwm-6.2/dwm.c b/dwm-6.2/dwm.c
index 27e1105..7d1582c 100644
--- a/dwm-6.2/dwm.c
+++ b/dwm-6.2/dwm.c
@@ -169,6 +169,7 @@ struct Systray {
};
/* 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);
@@ -270,6 +271,8 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
+static void bstack(Monitor *m);
+static void bstackhoriz(Monitor *m);
/* variables */
static Systray *systray = NULL;
@@ -324,6 +327,25 @@ 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[lpm[i]].symbol, sizeof m->ltsymbol);
+ for (i = 0; i <= LENGTH(tags); i++) {
+ m->pertag->ltidxs[i][0] = m->lt[0];
+ m->pertag->ltidxs[i][1] = m->lt[1];
+ }
+ }
+ i++;
+ }
+}
+
+void
applyrules(Client *c)
{
const char *class, *instance;
@@ -1913,11 +1935,11 @@ tile(Monitor *m)
for (i = my = ty = 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), 0);
+ resize(c, m->wx + m->ww - mw, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
my += HEIGHT(c);
} else {
h = (m->wh - ty) / (n - i);
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
+ resize(c, m->wx, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
ty += HEIGHT(c);
}
}
@@ -2178,6 +2200,7 @@ updategeom(void)
cleanupmon(m);
}
}
+ applydefaultlayouts();
free(unique);
} else
#endif /* XINERAMA */
@@ -2587,3 +2610,65 @@ main(int argc, char *argv[])
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}
+
+static void
+bstack(Monitor *m) {
+ int w, h, mh, mx, tx, ty, tw;
+ unsigned int i, n;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+ if (n > m->nmaster) {
+ mh = m->nmaster ? m->mfact * m->wh : 0;
+ tw = m->ww / (n - m->nmaster);
+ ty = m->wy + mh;
+ } else {
+ mh = m->wh;
+ tw = m->ww;
+ ty = m->wy;
+ }
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ h = m->wh - mh;
+ resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
+ if (tw != m->ww)
+ tx += WIDTH(c);
+ }
+ }
+}
+
+static void
+bstackhoriz(Monitor *m) {
+ int w, mh, mx, tx, ty, th;
+ unsigned int i, n;
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (n == 0)
+ return;
+ if (n > m->nmaster) {
+ mh = m->nmaster ? m->mfact * m->wh : 0;
+ th = (m->wh - mh) / (n - m->nmaster);
+ ty = m->wy + mh;
+ } else {
+ th = mh = m->wh;
+ ty = m->wy;
+ }
+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i < m->nmaster) {
+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
+ mx += WIDTH(c);
+ } else {
+ resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
+ if (th != m->wh)
+ ty += HEIGHT(c);
+ }
+ }
+}