05-dwm-fullgaps-6.4.diff (2418B)
1 diff -up a/config.def.h b/config.def.h 2 --- a/config.def.h 3 +++ b/config.def.h 4 @@ -2,6 +2,7 @@ 5 6 /* appearance */ 7 static const unsigned int borderpx = 1; /* border pixel of windows */ 8 +static const unsigned int gappx = 5; /* gaps between windows */ 9 static const unsigned int snap = 32; /* snap pixel */ 10 static const int showbar = 1; /* 0 means no bar */ 11 static const int topbar = 1; /* 0 means bottom bar */ 12 diff -up a/dwm.c b/dwm.c 13 --- a/dwm.c 2023-04-30 14 +++ b/dwm.c 2023-04-30 15 @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor * 16 static void setclientstate(Client *c, long state); 17 static void setfocus(Client *c); 18 static void setfullscreen(Client *c, int fullscreen); 19 +static void setgaps(const Arg *arg); 20 static void setlayout(const Arg *arg); 21 static void setmfact(const Arg *arg); 22 static void setup(void); 23 @@ -1508,6 +1511,16 @@ setfullscreen(Client *c, int fullscreen) 24 } 25 26 void 27 +setgaps(const Arg *arg) 28 +{ 29 + if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) 30 + selmon->gappx = 0; 31 + else 32 + selmon->gappx += arg->i; 33 + arrange(selmon); 34 +} 35 + 36 +void 37 setlayout(const Arg *arg) 38 { 39 if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) 40 @@ -1697,18 +1710,18 @@ tile(Monitor *m) 41 if (n > m->nmaster) 42 mw = m->nmaster ? m->ww * m->mfact : 0; 43 else 44 - mw = m->ww; 45 - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 46 - if (i < m->nmaster) { 47 - h = (m->wh - my) / (MIN(n, m->nmaster) - i); 48 - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); 49 - if (my + HEIGHT(c) < m->wh) 50 - my += HEIGHT(c); 51 + mw = m->ww - m->gappx; 52 + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 53 + if (i < m->nmaster) { 54 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; 55 + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); 56 + if (my + HEIGHT(c) + m->gappx < m->wh) 57 + my += HEIGHT(c) + m->gappx; 58 } else { 59 - h = (m->wh - ty) / (n - i); 60 - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); 61 - if (ty + HEIGHT(c) < m->wh) 62 - ty += HEIGHT(c); 63 + h = (m->wh - ty) / (n - i) - m->gappx; 64 + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0); 65 + if (ty + HEIGHT(c) + m->gappx < m->wh) 66 + ty += HEIGHT(c) + m->gappx; 67 } 68 }