1 From 7b7773458c072e4b24d6ea32d0364a8e402e4a43 Mon Sep 17 00:00:00 2001
2 From: swy7ch <swy7ch@protonmail.com>
3 Date: Fri, 8 May 2020 19:07:24 +0200
4 Subject: [PATCH] [PATCH] update dwm-fullgaps patch to be used with tile layout
7 the recent tile layout changes in commit HEAD~1 (f09418b) broke the
10 this patch adapt the new `if` statements to take gaps into account
12 this patch also provides manpage entries for the keybindings
16 dwm.c | 33 +++++++++++++++++++++++----------
17 3 files changed, 37 insertions(+), 10 deletions(-)
19 diff --git a/config.def.h b/config.def.h
20 index 1c0b587..38d2f6c 100644
26 static const unsigned int borderpx = 1; /* border pixel of windows */
27 +static const unsigned int gappx = 5; /* gaps between windows */
28 static const unsigned int snap = 32; /* snap pixel */
29 static const int showbar = 1; /* 0 means no bar */
30 static const int topbar = 1; /* 0 means bottom bar */
31 @@ -84,6 +85,9 @@ static Key keys[] = {
32 { MODKEY, XK_period, focusmon, {.i = +1 } },
33 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
34 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
35 + { MODKEY, XK_minus, setgaps, {.i = -1 } },
36 + { MODKEY, XK_equal, setgaps, {.i = +1 } },
37 + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
41 diff --git a/dwm.1 b/dwm.1
42 index 13b3729..0202d96 100644
45 @@ -140,6 +140,16 @@ View all windows with any tag.
46 .B Mod1\-Control\-[1..n]
47 Add/remove all windows with nth tag to/from the view.
50 +Decrease the gaps around windows.
53 +Increase the gaps around windows.
56 +Reset the gaps around windows to
62 diff --git a/dwm.c b/dwm.c
63 index 9fd0286..45a58f3 100644
66 @@ -119,6 +119,7 @@ struct Monitor {
67 int by; /* bar geometry */
68 int mx, my, mw, mh; /* screen size */
69 int wx, wy, ww, wh; /* window area */
70 + int gappx; /* gaps between windows */
73 unsigned int tagset[2];
74 @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
75 static void setclientstate(Client *c, long state);
76 static void setfocus(Client *c);
77 static void setfullscreen(Client *c, int fullscreen);
78 +static void setgaps(const Arg *arg);
79 static void setlayout(const Arg *arg);
80 static void setmfact(const Arg *arg);
81 static void setup(void);
82 @@ -639,6 +641,7 @@ createmon(void)
87 m->lt[0] = &layouts[0];
88 m->lt[1] = &layouts[1 % LENGTH(layouts)];
89 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
90 @@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen)
95 +setgaps(const Arg *arg)
97 + if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
100 + selmon->gappx += arg->i;
105 setlayout(const Arg *arg)
107 @@ -1684,18 +1697,18 @@ tile(Monitor *m)
109 mw = m->nmaster ? m->ww * m->mfact : 0;
112 - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
113 + mw = m->ww - m->gappx;
114 + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
115 if (i < m->nmaster) {
116 - h = (m->wh - my) / (MIN(n, m->nmaster) - i);
117 - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
118 - if (my + HEIGHT(c) < m->wh)
120 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
121 + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
122 + if (my + HEIGHT(c) + m->gappx < m->wh)
123 + my += HEIGHT(c) + m->gappx;
125 - h = (m->wh - ty) / (n - i);
126 - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
127 - if (ty + HEIGHT(c) < m->wh)
129 + h = (m->wh - ty) / (n - i) - m->gappx;
130 + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
131 + if (ty + HEIGHT(c) + m->gappx < m->wh)
132 + ty += HEIGHT(c) + m->gappx;