dwm-functionalgaps-6.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-functionalgaps-6.2.diff (8311B)
---
1 diff -pur dwm.git/config.def.h dwm.mygaps/config.def.h
2 --- dwm.git/config.def.h 2021-02-27 21:17:53.862314811 -0600
3 +++ dwm.mygaps/config.def.h 2021-02-28 00:06:39.066149441 -0600
4 @@ -2,6 +2,8 @@
5
6 /* appearance */
7 static const unsigned int borderpx = 1; /* border pixel of windows */
8 +static const int startwithgaps = 0; /* 1 means gaps are used by default */
9 +static const unsigned int gappx = 10; /* default gap between windows in pixels */
10 static const unsigned int snap = 32; /* snap pixel */
11 static const int showbar = 1; /* 0 means no bar */
12 static const int topbar = 1; /* 0 means bottom bar */
13 @@ -84,6 +86,10 @@ static Key keys[] = {
14 { MODKEY, XK_period, focusmon, {.i = +1 } },
15 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
16 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
17 + { MODKEY, XK_minus, setgaps, {.i = -5 } },
18 + { MODKEY, XK_equal, setgaps, {.i = +5 } },
19 + { MODKEY|ShiftMask, XK_minus, setgaps, {.i = GAP_RESET } },
20 + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = GAP_TOGGLE} },
21 TAGKEYS( XK_1, 0)
22 TAGKEYS( XK_2, 1)
23 TAGKEYS( XK_3, 2)
24 diff -pur dwm.git/dwm.c dwm.mygaps/dwm.c
25 --- dwm.git/dwm.c 2021-02-27 21:17:53.862314811 -0600
26 +++ dwm.mygaps/dwm.c 2021-02-28 00:23:19.232865766 -0600
27 @@ -57,6 +57,9 @@
28 #define TAGMASK ((1 << LENGTH(tags)) - 1)
29 #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
30
31 +#define GAP_TOGGLE 100
32 +#define GAP_RESET 0
33 +
34 /* enums */
35 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
36 enum { SchemeNorm, SchemeSel }; /* color schemes */
37 @@ -119,6 +122,8 @@ struct Monitor {
38 int by; /* bar geometry */
39 int mx, my, mw, mh; /* screen size */
40 int wx, wy, ww, wh; /* window area */
41 + int gappx; /* gaps between windows */
42 + int drawwithgaps; /* toggle gaps */
43 unsigned int seltags;
44 unsigned int sellt;
45 unsigned int tagset[2];
46 @@ -200,6 +205,7 @@ static void sendmon(Client *c, Monitor *
47 static void setclientstate(Client *c, long state);
48 static void setfocus(Client *c);
49 static void setfullscreen(Client *c, int fullscreen);
50 +static void setgaps(const Arg *arg);
51 static void setlayout(const Arg *arg);
52 static void setmfact(const Arg *arg);
53 static void setup(void);
54 @@ -639,6 +645,8 @@ createmon(void)
55 m->nmaster = nmaster;
56 m->showbar = showbar;
57 m->topbar = topbar;
58 + m->gappx = gappx;
59 + m->drawwithgaps = startwithgaps;
60 m->lt[0] = &layouts[0];
61 m->lt[1] = &layouts[1 % LENGTH(layouts)];
62 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
63 @@ -797,6 +805,12 @@ focus(Client *c)
64 attachstack(c);
65 grabbuttons(c, 1);
66 XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
67 + if (!selmon->drawwithgaps && !c->isfloating) {
68 + XWindowChanges wc;
69 + wc.sibling = selmon->barwin;
70 + wc.stack_mode = Below;
71 + XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
72 + }
73 setfocus(c);
74 } else {
75 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
76 @@ -1113,7 +1127,10 @@ monocle(Monitor *m)
77 if (n > 0) /* override layout symbol */
78 snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
79 for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
80 - resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
81 + if (selmon->drawwithgaps)
82 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
83 + else
84 + resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
85 }
86
87 void
88 @@ -1283,6 +1300,15 @@ resizeclient(Client *c, int x, int y, in
89 c->oldw = c->w; c->w = wc.width = w;
90 c->oldh = c->h; c->h = wc.height = h;
91 wc.border_width = c->bw;
92 + if (!selmon->drawwithgaps && /* this is the noborderfloatingfix patch, slightly modified so that it will work if, and only if, gaps are disabled. */
93 + (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) /* these two first lines are the only ones changed. if you are manually patching and have noborder installed already, just change these lines; or conversely, just remove this section if the noborder patch is not desired ;) */
94 + || &monocle == c->mon->lt[c->mon->sellt]->arrange))
95 + && !c->isfullscreen && !c->isfloating
96 + && NULL != c->mon->lt[c->mon->sellt]->arrange) {
97 + c->w = wc.width += c->bw * 2;
98 + c->h = wc.height += c->bw * 2;
99 + wc.border_width = 0;
100 + }
101 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
102 configure(c);
103 XSync(dpy, False);
104 @@ -1499,6 +1525,26 @@ setfullscreen(Client *c, int fullscreen)
105 }
106
107 void
108 +setgaps(const Arg *arg)
109 +{
110 + switch(arg->i)
111 + {
112 + case GAP_TOGGLE:
113 + selmon->drawwithgaps = !selmon->drawwithgaps;
114 + break;
115 + case GAP_RESET:
116 + selmon->gappx = gappx;
117 + break;
118 + default:
119 + if (selmon->gappx + arg->i < 0)
120 + selmon->gappx = 0;
121 + else
122 + selmon->gappx += arg->i;
123 + }
124 + arrange(selmon);
125 +}
126 +
127 +void
128 setlayout(const Arg *arg)
129 {
130 if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
131 @@ -1680,23 +1726,42 @@ tile(Monitor *m)
132 for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
133 if (n == 0)
134 return;
135 -
136 - if (n > m->nmaster)
137 - mw = m->nmaster ? m->ww * m->mfact : 0;
138 - else
139 - mw = m->ww;
140 - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
141 - if (i < m->nmaster) {
142 - h = (m->wh - my) / (MIN(n, m->nmaster) - i);
143 - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
144 - if (my + HEIGHT(c) < m->wh)
145 - my += HEIGHT(c);
146 - } else {
147 - h = (m->wh - ty) / (n - i);
148 - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
149 - if (ty + HEIGHT(c) < m->wh)
150 - ty += HEIGHT(c);
151 - }
152 + if (m->drawwithgaps) { /* draw with fullgaps logic */
153 + if (n > m->nmaster)
154 + mw = m->nmaster ? m->ww * m->mfact : 0;
155 + else
156 + mw = m->ww - m->gappx;
157 + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
158 + if (i < m->nmaster) {
159 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
160 + resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
161 + if (my + HEIGHT(c) + m->gappx < m->wh)
162 + my += HEIGHT(c) + m->gappx;
163 + } else {
164 + h = (m->wh - ty) / (n - i) - m->gappx;
165 + resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
166 + if (ty + HEIGHT(c) + m->gappx < m->wh)
167 + ty += HEIGHT(c) + m->gappx;
168 + }
169 + } else { /* draw with singularborders logic */
170 + if (n > m->nmaster)
171 + mw = m->nmaster ? m->ww * m->mfact : 0;
172 + else
173 + mw = m->ww;
174 + for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
175 + if (i < m->nmaster) {
176 + h = (m->wh - my) / (MIN(n, m->nmaster) - i);
177 + if (n == 1)
178 + resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
179 + else
180 + resize(c, m->wx - c->bw, m->wy + my, mw - c->bw, h - c->bw, False);
181 + my += HEIGHT(c) - c->bw;
182 + } else {
183 + h = (m->wh - ty) / (n - i);
184 + resize(c, m->wx + mw - c->bw, m->wy + ty, m->ww - mw, h - c->bw, False);
185 + ty += HEIGHT(c) - c->bw;
186 + }
187 + }
188 }
189
190 void