dwm

Fork of suckless' dwm with my personal patches
git clone https://git.instinctive.eu/dwm.git
Log | Files | Refs | README | LICENSE

commit cdce962fd063273e6703293aa409c8d350c4f312
parent d71541343ea1b6629e10d53d87787a312243430c
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Sun, 21 May 2023 00:39:52 +0200

[nat] add fixed-pixel layouts

Diffstat:
Mconfig.def.h | 6++++++
Mdwm.c | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -39,6 +39,8 @@ 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 lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ +static const int pixelwidth = 566; /* Master width in pixel* layouts */ +static const int pixelheight = 846; /* Master height in pixel* layouts */ static const Layout layouts[] = { /* symbol arrange function */ @@ -46,6 +48,8 @@ static const Layout layouts[] = { { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, { "[D]", deck }, + { "Pr", pixelrow }, + { "Pc", pixeldeckcol }, }; /* key definitions */ @@ -89,6 +93,8 @@ static const Key keys[] = { { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_r, setlayout, {.v = &layouts[3]} }, + { MODKEY|ControlMask, XK_p, setlayout, {.v = &layouts[4]} }, + { MODKEY|ControlMask|ShiftMask, XK_p, setlayout, {.v = &layouts[5]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/dwm.c b/dwm.c @@ -193,6 +193,8 @@ static void monocle(Monitor *m); static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); +static void pixeldeckcol(Monitor *m); +static void pixelrow(Monitor *m); static void pop(Client *c); static void propertynotify(XEvent *e); static void quit(const Arg *arg); @@ -1383,6 +1385,56 @@ nexttiled(Client *c) } void +pixeldeckcol(Monitor *m) +{ + unsigned int i, n, ty; + unsigned int nmaster = MIN(m->nmaster, (m->wh + pixelheight - 1) / pixelheight); + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + snprintf(m->ltsymbol, sizeof m->ltsymbol, "%s%d", selmon->lt[selmon->sellt]->symbol, n - MIN(m->nmaster, n)); + + for (i = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < nmaster - 1) { + resize(c, m->wx, m->wy + ty, pixelwidth - (2*c->bw), pixelheight - (2*c->bw), 0); + ty += pixelheight; + } else if (i == nmaster - 1) { + resize(c, m->wx, m->wy + ty, pixelwidth - (2*c->bw), m->wh - ty - (2*c->bw), 0); + ty = 0; + } else + resize(c, m->wx + pixelwidth, m->wy + ty, m->ww - pixelwidth - (2*c->bw), m->wh - (2*c->bw), 0); +} + +void +pixelrow(Monitor *m) +{ + unsigned int i, n, w, tx; + unsigned int nmaster = MIN(m->nmaster, (m->ww + pixelwidth - 1) / pixelwidth); + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + + for (i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < nmaster - 1) { + resize(c, m->wx + tx, m->wy, pixelwidth - (2*c->bw), pixelheight - (2*c->bw), 0); + tx += pixelwidth; + } else if (i == nmaster - 1) { + resize(c, m->wx + tx, m->wy, m->ww - tx - (2*c->bw), pixelheight - (2*c->bw), 0); + tx = 0; + } else { + w = (m->ww - tx) / (n - i); + resize(c, m->wx + tx, m->wy + pixelheight, w - (2*c->bw), m->wh - pixelheight - (2*c->bw), 0); + if (tx + WIDTH(c) < m->ww) + tx += WIDTH(c); + } +} + +void pop(Client *c) { detach(c);