dwm-fullgaps-20200504-b2e1dfc.diff (4653B)
1 From b2e1dfc554f2e12ecbf2dc0f2714aab99cae7174 Mon Sep 17 00:00:00 2001 2 From: swy7ch <swy7ch@protonmail.com> 3 Date: Mon, 4 May 2020 03:53:40 +0200 4 Subject: [PATCH] update dwm-fullgaps patch to be used with tile layout update 5 6 the recent tile layout changes in commit HEAD~1 (f09418b) broke the 7 patch 8 9 this patch adapt the new `if` statements to take gaps into account 10 11 this patch also provides manpage entries for the keybindings 12 --- 13 config.def.h | 4 ++++ 14 dwm.1 | 10 ++++++++++ 15 dwm.c | 33 +++++++++++++++++++++++---------- 16 3 files changed, 37 insertions(+), 10 deletions(-) 17 18 diff --git a/config.def.h b/config.def.h 19 index 1c0b587..38d2f6c 100644 20 --- a/config.def.h 21 +++ b/config.def.h 22 @@ -2,6 +2,7 @@ 23 24 /* appearance */ 25 static const unsigned int borderpx = 1; /* border pixel of windows */ 26 +static const unsigned int gappx = 5; /* gaps between windows */ 27 static const unsigned int snap = 32; /* snap pixel */ 28 static const int showbar = 1; /* 0 means no bar */ 29 static const int topbar = 1; /* 0 means bottom bar */ 30 @@ -84,6 +85,9 @@ static Key keys[] = { 31 { MODKEY, XK_period, focusmon, {.i = +1 } }, 32 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, 33 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, 34 + { MODKEY, XK_minus, setgaps, {.i = -1 } }, 35 + { MODKEY, XK_equal, setgaps, {.i = +1 } }, 36 + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, 37 TAGKEYS( XK_1, 0) 38 TAGKEYS( XK_2, 1) 39 TAGKEYS( XK_3, 2) 40 diff --git a/dwm.1 b/dwm.1 41 index 13b3729..0adb50c 100644 42 --- a/dwm.1 43 +++ b/dwm.1 44 @@ -140,6 +140,16 @@ View all windows with any tag. 45 .B Mod1\-Control\-[1..n] 46 Add/remove all windows with nth tag to/from the view. 47 .TP 48 +.B Mod1\-- 49 +Decrease the gaps around windows. 50 +.TP 51 +.B Mod1\-= 52 +Increase the gaps around windows. 53 +.TP 54 +.B Mod1\-Shift\-= 55 +Reset the gaps around windows to 56 +.BR 0. 57 +.TP 58 .B Mod1\-Shift\-q 59 Quit dwm. 60 .SS Mouse commands 61 diff --git a/dwm.c b/dwm.c 62 index 9fd0286..45a58f3 100644 63 --- a/dwm.c 64 +++ b/dwm.c 65 @@ -119,6 +119,7 @@ struct Monitor { 66 int by; /* bar geometry */ 67 int mx, my, mw, mh; /* screen size */ 68 int wx, wy, ww, wh; /* window area */ 69 + int gappx; /* gaps between windows */ 70 unsigned int seltags; 71 unsigned int sellt; 72 unsigned int tagset[2]; 73 @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m); 74 static void setclientstate(Client *c, long state); 75 static void setfocus(Client *c); 76 static void setfullscreen(Client *c, int fullscreen); 77 +static void setgaps(const Arg *arg); 78 static void setlayout(const Arg *arg); 79 static void setmfact(const Arg *arg); 80 static void setup(void); 81 @@ -639,6 +641,7 @@ createmon(void) 82 m->nmaster = nmaster; 83 m->showbar = showbar; 84 m->topbar = topbar; 85 + m->gappx = gappx; 86 m->lt[0] = &layouts[0]; 87 m->lt[1] = &layouts[1 % LENGTH(layouts)]; 88 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); 89 @@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen) 90 } 91 } 92 93 +void 94 +setgaps(const Arg *arg) 95 +{ 96 + if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) 97 + selmon->gappx = 0; 98 + else 99 + selmon->gappx += arg->i; 100 + arrange(selmon); 101 +} 102 + 103 void 104 setlayout(const Arg *arg) 105 { 106 @@ -1684,18 +1697,18 @@ tile(Monitor *m) 107 if (n > m->nmaster) 108 mw = m->nmaster ? m->ww * m->mfact : 0; 109 else 110 - mw = m->ww; 111 - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 112 + mw = m->ww - m->gappx; 113 + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 114 if (i < m->nmaster) { 115 - h = (m->wh - my) / (MIN(n, m->nmaster) - i); 116 - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); 117 - if (my + HEIGHT(c) < m->wh) 118 - my += HEIGHT(c); 119 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; 120 + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); 121 + if (my + HEIGHT(c) + m->gappx < m->wh) 122 + my += HEIGHT(c) + m->gappx; 123 } else { 124 - h = (m->wh - ty) / (n - i); 125 - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); 126 - if (ty + HEIGHT(c) < m->wh) 127 - ty += HEIGHT(c); 128 + h = (m->wh - ty) / (n - i) - m->gappx; 129 + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0); 130 + if (ty + HEIGHT(c) + m->gappx < m->wh) 131 + ty += HEIGHT(c) + m->gappx; 132 } 133 } 134 135 -- 136 2.26.2 137