summaryrefslogtreecommitdiff
path: root/dwm-6.2/dwm.c
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 /dwm-6.2/dwm.c
parent67b505107e8c8075b409bdc7a7a8a0158caf4aa6 (diff)
[dwm] rstack hack, bstack{,horiz}, default per monitor
Diffstat (limited to 'dwm-6.2/dwm.c')
-rw-r--r--dwm-6.2/dwm.c89
1 files changed, 87 insertions, 2 deletions
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);
+ }
+ }
+}