dwm

my heavily-patched and customized dwm build
git clone git://git.kocotian.pl/dwm.git
Log | Files | Refs | README | LICENSE

commit 2486485fd23c01ea7c3dae4e112914a9d74957f3
parent 7c88139eab0a136dac2f67bd55ff66bdf7691011
Author: kocotian <kocotian@kocotian.pl>
Date:   Sat, 12 Dec 2020 12:21:08 +0100

cfacts, layouts

Diffstat:
MREADME | 7+++++++
Mconfig.def.h | 16+++++++++++++---
Mconfig.def.h.orig | 29++++++++++++++++++++---------
Aconfig.def.h.rej | 20++++++++++++++++++++
Adrw.o | 0
Adwm | 0
Mdwm.c | 263++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mdwm.c.orig | 130++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Mdwm.c.rej | 41++++++++++-------------------------------
Adwm.o | 0
Mpatches/dwm-cfacts-20200913-61bb8b2.diff | 0
Mpatches/dwm-cfacts_bottomstack-6.2.diff | 0
Mpatches/dwm-cfacts_centeredmaster-6.2.diff | 0
Autil.o | 0
14 files changed, 452 insertions(+), 54 deletions(-)

diff --git a/README b/README @@ -19,6 +19,13 @@ necessary as root): make clean install +Patches +------- +All patches are in patches directory, applied patches has additional +executable permission (for readibility reasons - colored ls displays +executables green). + + Running dwm ----------- Add the following line to your .xinitrc to start dwm using startx: diff --git a/config.def.h b/config.def.h @@ -49,8 +49,12 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ + { "TTT", bstack }, + { "===", bstackhoriz }, { "[M]", monocle }, + { "|M|", centeredmaster }, + { ">M>", centeredfloatingmaster }, + { "><>", NULL }, /* no layout function means floating behavior */ }; /* key definitions */ @@ -73,9 +77,13 @@ static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_r, setcfact, {.f = 0.00} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_y, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_u, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_y, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_u, setlayout, {.v = &layouts[4]} }, + { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[5]} }, { MODKEY, XK_o, incnmaster, {.i = +1 } }, { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } }, @@ -84,6 +92,8 @@ static Key keys[] = { { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_h, setcfact, {.f = -0.25} }, + { MODKEY|ShiftMask, XK_l, setcfact, {.f = +0.25} }, { MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_z, setlayout, {0} }, diff --git a/config.def.h.orig b/config.def.h.orig @@ -14,9 +14,14 @@ static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_cyan[] = "#005577"; static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeStatus] = { col_gray3, col_gray1, "#000000" }, /* Status */ + [SchemeTagsSel] = { col_gray4, col_cyan, "#000000" }, /* Tagbar l selected */ + [SchemeTagsNorm] = { col_gray3, col_gray1, "#000000" }, /* Tagbar l unselected */ + [SchemeInfoSel] = { col_gray3, col_gray1, "#000000" }, /* Infbar m selected */ + [SchemeInfoNorm] = { col_gray3, col_gray1, "#000000" }, /* Infbar m unselected */ }; /* tagging */ @@ -29,12 +34,11 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, { "discord", NULL, NULL, 1 << 7, 0, -1 }, - { "st-256color", NULL, NULL, 0, 0, -1 }, + { "qutebrowser", NULL, NULL, 1 << 1, 0, -1 }, + { "st-256color", NULL, NULL, 0 << 0, 0, -1 }, { "Pulseeffects", NULL, NULL, 1 << 8, 0, 1 }, { "TelegramDesktop", NULL, NULL, 1 << 6, 0, -1 }, - { "Microsoft Teams - Preview", NULL, NULL, 1 << 0, 0, 1 }, }; /* layout(s) */ @@ -47,6 +51,8 @@ static const Layout layouts[] = { { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "TTT", bstack }, + { "===", bstackhoriz }, }; /* key definitions */ @@ -69,9 +75,12 @@ static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_r, setcfact, {.f = 0.00} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_y, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_u, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_y, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_u, setlayout, {.v = &layouts[4]} }, { MODKEY, XK_o, incnmaster, {.i = +1 } }, { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } }, @@ -80,8 +89,11 @@ static Key keys[] = { { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_h, setcfact, {.f = -0.25} }, + { MODKEY|ShiftMask, XK_l, setcfact, {.f = +0.25} }, { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_z, setlayout, {0} }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, @@ -89,7 +101,6 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, { MODKEY, XK_space, zoom, {0} }, - { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/config.def.h.rej b/config.def.h.rej @@ -0,0 +1,20 @@ +--- config.def.h 2019-06-05 02:24:05.503321320 +0200 ++++ config.def.h 2019-06-05 10:46:48.099997829 +0200 +@@ -41,6 +41,8 @@ static const Layout layouts[] = { + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "|M|", centeredmaster }, ++ { ">M>", centeredfloatingmaster }, + }; + + /* key definitions */ +@@ -79,6 +81,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/drw.o b/drw.o Binary files differ. diff --git a/dwm b/dwm Binary files differ. diff --git a/dwm.c b/dwm.c @@ -87,6 +87,7 @@ typedef struct Client Client; struct Client { char name[256]; float mina, maxa; + float cfact; int x, y, w, h; int oldx, oldy, oldw, oldh; int basew, baseh, incw, inch, maxw, maxh, minw, minh; @@ -148,7 +149,11 @@ static void arrange(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); static void attachstack(Client *c); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); static void buttonpress(XEvent *e); +static void centeredmaster(Monitor *m); +static void centeredfloatingmaster(Monitor *m); static void checkotherwm(void); static void cleanup(void); static void cleanupmon(Monitor *mon); @@ -201,6 +206,7 @@ static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); static void setlayout(const Arg *arg); +static void setcfact(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); @@ -1033,6 +1039,7 @@ manage(Window w, XWindowAttributes *wa) c->w = c->oldw = wa->width; c->h = c->oldh = wa->height; c->oldbw = wa->border_width; + c->cfact = 1.0; updatetitle(c); if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { @@ -1516,6 +1523,23 @@ setlayout(const Arg *arg) drawbar(selmon); } +void setcfact(const Arg *arg) { + float f; + Client *c; + + c = selmon->sel; + + if(!arg || !c || !selmon->lt[selmon->sellt]->arrange) + return; + f = arg->f + c->cfact; + if(arg->f == 0.0) + f = 1.0; + else if(f < 0.25 || f > 4.0) + return; + c->cfact = f; + arrange(selmon); +} + /* arg > 1.0 will set mfact absolutely */ void setmfact(const Arg *arg) @@ -1696,9 +1720,15 @@ void tile(Monitor *m) { unsigned int i, n, h, mw, my, ty; + float mfacts = 0, sfacts = 0; Client *c; - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } if (n == 0) return; @@ -1708,15 +1738,17 @@ tile(Monitor *m) mw = m->ww; 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); + h = (m->wh - my) * (c->cfact / mfacts); resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); if (my + HEIGHT(c) < m->wh) my += HEIGHT(c); + mfacts -= c->cfact; } else { - h = (m->wh - ty) / (n - i); + h = (m->wh - ty) * (c->cfact / sfacts); resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); if (ty + HEIGHT(c) < m->wh) ty += HEIGHT(c); + sfacts -= c->cfact; } } @@ -2172,3 +2204,228 @@ main(int argc, char *argv[]) XCloseDisplay(dpy); return EXIT_SUCCESS; } + +void +bstack(Monitor *m) +{ + unsigned int i, n, w, mh, mx, tx; + float mfacts = 0, sfacts = 0; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } + if (n == 0) + return; + if(n == 1){ + c = nexttiled(m->clients); + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + return; + } + + if (n > m->nmaster) + mh = m->nmaster ? m->wh * m->mfact : 0; + else + mh = m->wh; + for (i = 0, mx = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + w = (m->ww - mx) * (c->cfact / mfacts); + resize(c, m->wx + mx, m->wy, w - (2*c->bw), mh - 2*c->bw, 0); + if(mx + WIDTH(c) < m->mw) + mx += WIDTH(c); + mfacts -= c->cfact; + } else { + w = (m->ww - tx) * (c->cfact / sfacts); + resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*(c->bw), 0); + if(tx + WIDTH(c) < m->mw) + tx += WIDTH(c); + sfacts -= c->cfact; + } +} + +void +bstackhoriz(Monitor *m) +{ + unsigned int i, n, h, mw, mh, my, ty; + float mfacts = 0, sfacts = 0; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } + if (n == 0) + return; + if(n == 1){ + c = nexttiled(m->clients); + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + return; + } + + if (n > m->nmaster) + mh = m->nmaster ? m->wh * m->mfact : 0; + else + mh = m->wh; + mw = m->ww; + + for (i = ty = 0, my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + h = (mh - my) * (c->cfact / mfacts); + resize(c, m->wx, m->wy + my, mw - 2*c->bw, h - 2*c->bw, 0); + if(my + HEIGHT(c) < m->mh) + my += HEIGHT(c); + mfacts -= c->cfact; + } else { + h = (m->wh - mh - ty) * (c->cfact / sfacts); + resize(c, m->wx, m->wy + mh + ty, mw - 2*c->bw, h - (2*c->bw), 0); + if(ty + HEIGHT(c) < m->mh) + ty += HEIGHT(c); + sfacts -= c->cfact; + } +} + +void +centeredmaster(Monitor *m) +{ + unsigned int i, n, h, mw, mx, my, oty, ety, tw; + float mfacts = 0, lfacts = 0, rfacts = 0; + Client *c; + + /* count number of clients in the selected monitor */ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else if ((n - m->nmaster) % 2) + lfacts += c->cfact; + else + rfacts += c->cfact; + } + if (n == 0) + return; + if(n == 1){ + c = nexttiled(m->clients); + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + return; + } + + /* initialize areas */ + mw = m->ww; + mx = 0; + my = 0; + tw = mw; + + if (n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + mw = m->nmaster ? m->ww * m->mfact : 0; + tw = m->ww - mw; + + if (n - m->nmaster > 1) { + /* only one client */ + mx = (m->ww - mw) / 2; + tw = (m->ww - mw) / 2; + } + } + + oty = 0; + ety = 0; + for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + /* nmaster clients are stacked vertically, in the center + * of the screen */ + h = (m->wh - my) * (c->cfact / mfacts); + resize(c, m->wx + mx, m->wy + my, mw - 2*c->bw, + h - 2*c->bw, 0); + if(my + HEIGHT(c) < m->mh) + my += HEIGHT(c); + mfacts -= c->cfact; + } else { + /* stack clients are stacked vertically */ + if ((i - m->nmaster) % 2) { + h = (m->wh - ety) * (c->cfact / lfacts); + if(m->nmaster == 0) + resize(c, m->wx, m->wy + ety, tw - 2*c->bw, + h - 2*c->bw, 0); + else + resize(c, m->wx, m->wy + ety, tw - 2*c->bw, + h - 2*c->bw, 0); + if(ety + HEIGHT(c) < m->mh) + ety += HEIGHT(c); + lfacts -= c->cfact; + } else { + h = (m->wh - oty) * (c->cfact / rfacts); + resize(c, m->wx + mx + mw, m->wy + oty, + tw - 2*c->bw, h - 2*c->bw, 0); + if(oty + HEIGHT(c) < m->mh) + oty += HEIGHT(c); + rfacts -= c->cfact; + } + } +} + +void +centeredfloatingmaster(Monitor *m) +{ + unsigned int i, n, w, mh, mw, mx, mxo, my, myo, tx; + float mfacts = 0, sfacts = 0; + Client *c; + + /* count number of clients in the selected monitor */ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } + if (n == 0) + return; + if(n == 1){ + c = nexttiled(m->clients); + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + return; + } + + /* initialize nmaster area */ + if (n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (m->ww > m->wh) { + mw = m->nmaster ? m->ww * m->mfact : 0; + mh = m->nmaster ? m->wh * 0.9 : 0; + } else { + mh = m->nmaster ? m->wh * m->mfact : 0; + mw = m->nmaster ? m->ww * 0.9 : 0; + } + mx = mxo = (m->ww - mw) / 2; + my = myo = (m->wh - mh) / 2; + } else { + /* go fullscreen if all clients are in the master area */ + mh = m->wh; + mw = m->ww; + mx = mxo = 0; + my = myo = 0; + } + + for(i = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + /* nmaster clients are stacked horizontally, in the center + * of the screen */ + w = (mw + mxo - mx) * (c->cfact / mfacts); + resize(c, m->wx + mx, m->wy + my, w - 2*c->bw, + mh - 2*c->bw, 0); + if(mx + WIDTH(c) < m->mw) + mx += WIDTH(c); + mfacts -= c->cfact; + } else { + /* stack clients are stacked horizontally */ + w = (m->ww - tx) * (c->cfact / sfacts); + resize(c, m->wx + tx, m->wy, w - 2*c->bw, + m->wh - 2*c->bw, 0); + if(tx + WIDTH(c) < m->mw) + tx += WIDTH(c); + sfacts -= c->cfact; + } +} diff --git a/dwm.c.orig b/dwm.c.orig @@ -59,7 +59,7 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeStatus, SchemeTagsSel, SchemeTagsNorm, SchemeInfoSel, SchemeInfoNorm }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ @@ -87,6 +87,7 @@ typedef struct Client Client; struct Client { char name[256]; float mina, maxa; + float cfact; int x, y, w, h; int oldx, oldy, oldw, oldh; int basew, baseh, incw, inch, maxw, maxh, minw, minh; @@ -201,6 +202,7 @@ static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); static void setlayout(const Arg *arg); +static void setcfact(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); @@ -236,6 +238,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 const char broken[] = "broken"; @@ -707,7 +711,7 @@ drawbar(Monitor *m) /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ - drw_setscheme(drw, scheme[SchemeNorm]); + drw_setscheme(drw, scheme[SchemeStatus]); tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); } @@ -720,7 +724,7 @@ drawbar(Monitor *m) x = 0; for (i = 0; i < LENGTH(tags); i++) { w = TEXTW(tags[i]); - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); if (occ & 1 << i) drw_rect(drw, x + boxs, boxs, boxw, boxw, @@ -734,12 +738,12 @@ drawbar(Monitor *m) if ((w = m->ww - tw - x) > bh) { if (m->sel) { - drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); + drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); if (m->sel->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); } else { - drw_setscheme(drw, scheme[SchemeNorm]); + drw_setscheme(drw, scheme[SchemeInfoNorm]); drw_rect(drw, x, 0, w, bh, 1, 1); } } @@ -1033,6 +1037,7 @@ manage(Window w, XWindowAttributes *wa) c->w = c->oldw = wa->width; c->h = c->oldh = wa->height; c->oldbw = wa->border_width; + c->cfact = 1.0; updatetitle(c); if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { @@ -1516,6 +1521,23 @@ setlayout(const Arg *arg) drawbar(selmon); } +void setcfact(const Arg *arg) { + float f; + Client *c; + + c = selmon->sel; + + if(!arg || !c || !selmon->lt[selmon->sellt]->arrange) + return; + f = arg->f + c->cfact; + if(arg->f == 0.0) + f = 1.0; + else if(f < 0.25 || f > 4.0) + return; + c->cfact = f; + arrange(selmon); +} + /* arg > 1.0 will set mfact absolutely */ void setmfact(const Arg *arg) @@ -1696,9 +1718,15 @@ void tile(Monitor *m) { unsigned int i, n, h, mw, my, ty; + float mfacts = 0, sfacts = 0; Client *c; - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } if (n == 0) return; @@ -1708,15 +1736,17 @@ tile(Monitor *m) mw = m->ww; 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); + h = (m->wh - my) * (c->cfact / mfacts); resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); if (my + HEIGHT(c) < m->wh) my += HEIGHT(c); + mfacts -= c->cfact; } else { - h = (m->wh - ty) / (n - i); + h = (m->wh - ty) * (c->cfact / sfacts); resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); if (ty + HEIGHT(c) < m->wh) ty += HEIGHT(c); + sfacts -= c->cfact; } } @@ -2172,3 +2202,87 @@ main(int argc, char *argv[]) XCloseDisplay(dpy); return EXIT_SUCCESS; } + +void +bstack(Monitor *m) +{ + unsigned int i, n, w, mh, mx, tx; + float mfacts = 0, sfacts = 0; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } + if (n == 0) + return; + if(n == 1){ + c = nexttiled(m->clients); + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + return; + } + + if (n > m->nmaster) + mh = m->nmaster ? m->wh * m->mfact : 0; + else + mh = m->wh; + for (i = 0, mx = tx = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + w = (m->ww - mx) * (c->cfact / mfacts); + resize(c, m->wx + mx, m->wy, w - (2*c->bw), mh - 2*c->bw, 0); + if(mx + WIDTH(c) < m->mw) + mx += WIDTH(c); + mfacts -= c->cfact; + } else { + w = (m->ww - tx) * (c->cfact / sfacts); + resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*(c->bw), 0); + if(tx + WIDTH(c) < m->mw) + tx += WIDTH(c); + sfacts -= c->cfact; + } +} + +void +bstackhoriz(Monitor *m) +{ + unsigned int i, n, h, mw, mh, my, ty; + float mfacts = 0, sfacts = 0; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { + if (n < m->nmaster) + mfacts += c->cfact; + else + sfacts += c->cfact; + } + if (n == 0) + return; + if(n == 1){ + c = nexttiled(m->clients); + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); + return; + } + + if (n > m->nmaster) + mh = m->nmaster ? m->wh * m->mfact : 0; + else + mh = m->wh; + mw = m->ww; + + for (i = ty = 0, my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { + h = (mh - my) * (c->cfact / mfacts); + resize(c, m->wx, m->wy + my, mw - 2*c->bw, h - 2*c->bw, 0); + if(my + HEIGHT(c) < m->mh) + my += HEIGHT(c); + mfacts -= c->cfact; + } else { + h = (m->wh - mh - ty) * (c->cfact / sfacts); + resize(c, m->wx, m->wy + mh + ty, mw - 2*c->bw, h - (2*c->bw), 0); + if(ty + HEIGHT(c) < m->mh) + ty += HEIGHT(c); + sfacts -= c->cfact; + } +} diff --git a/dwm.c.rej b/dwm.c.rej @@ -1,32 +1,11 @@ ---- dwm.c -+++ dwm.c -@@ -703,7 +703,7 @@ drawbar(Monitor *m) +--- dwm.c 2019-06-05 02:25:40.169986187 +0200 ++++ dwm.c 2019-06-05 10:48:42.443328992 +0200 +@@ -235,6 +235,8 @@ static int xerror(Display *dpy, XErrorEv + static int xerrordummy(Display *dpy, XErrorEvent *ee); + static int xerrorstart(Display *dpy, XErrorEvent *ee); + static void zoom(const Arg *arg); ++static void centeredmaster(Monitor *m); ++static void centeredfloatingmaster(Monitor *m); - /* draw status first so it can be overdrawn by tags later */ - if (m == selmon) { /* status is only drawn on selected monitor */ -- drw_setscheme(drw, scheme[SchemeNorm]); -+ drw_setscheme(drw, scheme[SchemeStatus]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); - } -@@ -725,17 +725,17 @@ drawbar(Monitor *m) - x += w; - } - w = blw = TEXTW(m->ltsymbol); -- drw_setscheme(drw, scheme[SchemeNorm]); -+ drw_setscheme(drw, scheme[SchemeTagsNorm]); - x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); - - if ((w = m->ww - sw - x) > bh) { - if (m->sel) { -- drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); -+ drw_setscheme(drw, scheme[m == selmon ? SchemeInfoSel : SchemeInfoNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); - if (m->sel->isfloating) - drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); - } else { -- drw_setscheme(drw, scheme[SchemeNorm]); -+ drw_setscheme(drw, scheme[SchemeInfoNorm]); - drw_rect(drw, x, 0, w, bh, 1, 1); - } - } + /* variables */ + static const char broken[] = "broken"; diff --git a/dwm.o b/dwm.o Binary files differ. diff --git a/patches/dwm-cfacts-20200913-61bb8b2.diff b/patches/dwm-cfacts-20200913-61bb8b2.diff diff --git a/patches/dwm-cfacts_bottomstack-6.2.diff b/patches/dwm-cfacts_bottomstack-6.2.diff diff --git a/patches/dwm-cfacts_centeredmaster-6.2.diff b/patches/dwm-cfacts_centeredmaster-6.2.diff diff --git a/util.o b/util.o Binary files differ.