dwm-cfacts-6.2-1.diff (3687B)
1 From ac76d998f1e70c89b313a2fea676678d511941d4 Mon Sep 17 00:00:00 2001 2 From: Tobias Giess <tobias.giess@gmail.com> 3 Date: Wed, 17 Jun 2020 19:13:02 +0200 4 Subject: [PATCH] fix cfacts not working on stack 5 6 One line got lost while porting the cfacts patch from version 6.1 to version 6.2. 7 This single line caused that the cfacts patch was only working on master clients 8 but not on stack clients. 9 --- 10 config.def.h | 3 +++ 11 dwm.c | 34 +++++++++++++++++++++++++++++++--- 12 2 files changed, 34 insertions(+), 3 deletions(-) 13 14 diff --git a/config.def.h b/config.def.h 15 index 1c0b587..83910c1 100644 16 --- a/config.def.h 17 +++ b/config.def.h 18 @@ -70,6 +70,9 @@ static Key keys[] = { 19 { MODKEY, XK_d, incnmaster, {.i = -1 } }, 20 { MODKEY, XK_h, setmfact, {.f = -0.05} }, 21 { MODKEY, XK_l, setmfact, {.f = +0.05} }, 22 + { MODKEY|ShiftMask, XK_h, setcfact, {.f = +0.25} }, 23 + { MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} }, 24 + { MODKEY|ShiftMask, XK_o, setcfact, {.f = 0.00} }, 25 { MODKEY, XK_Return, zoom, {0} }, 26 { MODKEY, XK_Tab, view, {0} }, 27 { MODKEY|ShiftMask, XK_c, killclient, {0} }, 28 diff --git a/dwm.c b/dwm.c 29 index 4465af1..c0ad1b3 100644 30 --- a/dwm.c 31 +++ b/dwm.c 32 @@ -87,6 +87,7 @@ typedef struct Client Client; 33 struct Client { 34 char name[256]; 35 float mina, maxa; 36 + float cfact; 37 int x, y, w, h; 38 int oldx, oldy, oldw, oldh; 39 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 40 @@ -200,6 +201,7 @@ static void setclientstate(Client *c, long state); 41 static void setfocus(Client *c); 42 static void setfullscreen(Client *c, int fullscreen); 43 static void setlayout(const Arg *arg); 44 +static void setcfact(const Arg *arg); 45 static void setmfact(const Arg *arg); 46 static void setup(void); 47 static void seturgent(Client *c, int urg); 48 @@ -1029,6 +1031,7 @@ manage(Window w, XWindowAttributes *wa) 49 c->w = c->oldw = wa->width; 50 c->h = c->oldh = wa->height; 51 c->oldbw = wa->border_width; 52 + c->cfact = 1.0; 53 54 updatetitle(c); 55 if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { 56 @@ -1511,6 +1514,23 @@ setlayout(const Arg *arg) 57 drawbar(selmon); 58 } 59 60 +void setcfact(const Arg *arg) { 61 + float f; 62 + Client *c; 63 + 64 + c = selmon->sel; 65 + 66 + if(!arg || !c || !selmon->lt[selmon->sellt]->arrange) 67 + return; 68 + f = arg->f + c->cfact; 69 + if(arg->f == 0.0) 70 + f = 1.0; 71 + else if(f < 0.25 || f > 4.0) 72 + return; 73 + c->cfact = f; 74 + arrange(selmon); 75 +} 76 + 77 /* arg > 1.0 will set mfact absolutely */ 78 void 79 setmfact(const Arg *arg) 80 @@ -1674,9 +1694,15 @@ void 81 tile(Monitor *m) 82 { 83 unsigned int i, n, h, mw, my, ty; 84 + float mfacts = 0, sfacts = 0; 85 Client *c; 86 87 - for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 88 + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) { 89 + if (n < m->nmaster) 90 + mfacts += c->cfact; 91 + else 92 + sfacts += c->cfact; 93 + } 94 if (n == 0) 95 return; 96 97 @@ -1686,13 +1712,15 @@ tile(Monitor *m) 98 mw = m->ww; 99 for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 100 if (i < m->nmaster) { 101 - h = (m->wh - my) / (MIN(n, m->nmaster) - i); 102 + h = (m->wh - my) * (c->cfact / mfacts); 103 resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); 104 my += HEIGHT(c); 105 + mfacts -= c->cfact; 106 } else { 107 - h = (m->wh - ty) / (n - i); 108 + h = (m->wh - ty) * (c->cfact / sfacts); 109 resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); 110 ty += HEIGHT(c); 111 + sfacts -= c->cfact; 112 } 113 } 114 115 -- 116 2.27.0 117