vanitygaps-0.7.patch (12364B)
1 From 3c95b58bc2b87ebd9b8481b3b16e49d99883f0a7 Mon Sep 17 00:00:00 2001 2 From: Bonicgamer <44382222+Bonicgamer@users.noreply.github.com> 3 Date: Mon, 17 Aug 2020 14:48:24 -0400 4 Subject: [PATCH 1/2] Implement vanitygaps 5 MIME-Version: 1.0 6 Content-Type: text/plain; charset=UTF-8 7 Content-Transfer-Encoding: 8bit 8 9 Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me> 10 --- 11 config.def.h | 21 ++++++++ 12 dwl.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++---- 13 2 files changed, 161 insertions(+), 10 deletions(-) 14 15 diff --git a/config.def.h b/config.def.h 16 index 22d2171d..39e528b1 100644 17 --- a/config.def.h 18 +++ b/config.def.h 19 @@ -6,7 +6,12 @@ 20 /* appearance */ 21 static const int sloppyfocus = 1; /* focus follows mouse */ 22 static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ 23 +static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ 24 static const unsigned int borderpx = 1; /* border pixel of windows */ 25 +static const unsigned int gappih = 10; /* horiz inner gap between windows */ 26 +static const unsigned int gappiv = 10; /* vert inner gap between windows */ 27 +static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ 28 +static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ 29 static const float rootcolor[] = COLOR(0x222222ff); 30 static const float bordercolor[] = COLOR(0x444444ff); 31 static const float focuscolor[] = COLOR(0x005577ff); 32 @@ -133,6 +138,22 @@ static const Key keys[] = { 33 { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, 34 { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} }, 35 { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, 36 + { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_h, incgaps, {.i = +1 } }, 37 + { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_l, incgaps, {.i = -1 } }, 38 + { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } }, 39 + { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_L, incogaps, {.i = -1 } }, 40 + { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_h, incigaps, {.i = +1 } }, 41 + { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_l, incigaps, {.i = -1 } }, 42 + { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_0, togglegaps, {0} }, 43 + { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,defaultgaps, {0} }, 44 + { MODKEY, XKB_KEY_y, incihgaps, {.i = +1 } }, 45 + { MODKEY, XKB_KEY_o, incihgaps, {.i = -1 } }, 46 + { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_y, incivgaps, {.i = +1 } }, 47 + { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_o, incivgaps, {.i = -1 } }, 48 + { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_y, incohgaps, {.i = +1 } }, 49 + { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_o, incohgaps, {.i = -1 } }, 50 + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y, incovgaps, {.i = +1 } }, 51 + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, incovgaps, {.i = -1 } }, 52 { MODKEY, XKB_KEY_Return, zoom, {0} }, 53 { MODKEY, XKB_KEY_Tab, view, {0} }, 54 { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} }, 55 diff --git a/dwl.c b/dwl.c 56 index a2711f67..d749728a 100644 57 --- a/dwl.c 58 +++ b/dwl.c 59 @@ -200,6 +200,10 @@ struct Monitor { 60 struct wlr_box w; /* window area, layout-relative */ 61 struct wl_list layers[4]; /* LayerSurface.link */ 62 const Layout *lt[2]; 63 + int gappih; /* horizontal gap between windows */ 64 + int gappiv; /* vertical gap between windows */ 65 + int gappoh; /* horizontal outer gaps */ 66 + int gappov; /* vertical outer gaps */ 67 unsigned int seltags; 68 unsigned int sellt; 69 uint32_t tagset[2]; 70 @@ -273,6 +277,7 @@ static void createpopup(struct wl_listener *listener, void *data); 71 static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint); 72 static void cursorframe(struct wl_listener *listener, void *data); 73 static void cursorwarptohint(void); 74 +static void defaultgaps(const Arg *arg); 75 static void destroydecoration(struct wl_listener *listener, void *data); 76 static void destroydragicon(struct wl_listener *listener, void *data); 77 static void destroyidleinhibitor(struct wl_listener *listener, void *data); 78 @@ -293,6 +298,13 @@ static void fullscreennotify(struct wl_listener *listener, void *data); 79 static void gpureset(struct wl_listener *listener, void *data); 80 static void handlesig(int signo); 81 static void incnmaster(const Arg *arg); 82 +static void incgaps(const Arg *arg); 83 +static void incigaps(const Arg *arg); 84 +static void incihgaps(const Arg *arg); 85 +static void incivgaps(const Arg *arg); 86 +static void incogaps(const Arg *arg); 87 +static void incohgaps(const Arg *arg); 88 +static void incovgaps(const Arg *arg); 89 static void inputdevice(struct wl_listener *listener, void *data); 90 static int keybinding(uint32_t mods, xkb_keysym_t sym); 91 static void keypress(struct wl_listener *listener, void *data); 92 @@ -327,6 +339,7 @@ static void setcursorshape(struct wl_listener *listener, void *data); 93 static void setfloating(Client *c, int floating); 94 static void setfullscreen(Client *c, int fullscreen); 95 static void setgamma(struct wl_listener *listener, void *data); 96 +static void setgaps(int oh, int ov, int ih, int iv); 97 static void setlayout(const Arg *arg); 98 static void setmfact(const Arg *arg); 99 static void setmon(Client *c, Monitor *m, uint32_t newtags); 100 @@ -340,6 +353,7 @@ static void tagmon(const Arg *arg); 101 static void tile(Monitor *m); 102 static void togglefloating(const Arg *arg); 103 static void togglefullscreen(const Arg *arg); 104 +static void togglegaps(const Arg *arg); 105 static void toggletag(const Arg *arg); 106 static void toggleview(const Arg *arg); 107 static void unlocksession(struct wl_listener *listener, void *data); 108 @@ -413,6 +427,8 @@ static struct wlr_box sgeom; 109 static struct wl_list mons; 110 static Monitor *selmon; 111 112 +static int enablegaps = 1; /* enables gaps, used by togglegaps */ 113 + 114 #ifdef XWAYLAND 115 static void activatex11(struct wl_listener *listener, void *data); 116 static void associatex11(struct wl_listener *listener, void *data); 117 @@ -989,6 +1005,11 @@ createmon(struct wl_listener *listener, void *data) 118 for (i = 0; i < LENGTH(m->layers); i++) 119 wl_list_init(&m->layers[i]); 120 121 + m->gappih = gappih; 122 + m->gappiv = gappiv; 123 + m->gappoh = gappoh; 124 + m->gappov = gappov; 125 + 126 wlr_output_state_init(&state); 127 /* Initialize monitor state using configured rules */ 128 m->tagset[0] = m->tagset[1] = 1; 129 @@ -1171,6 +1192,12 @@ cursorwarptohint(void) 130 } 131 } 132 133 +void 134 +defaultgaps(const Arg *arg) 135 +{ 136 + setgaps(gappoh, gappov, gappih, gappiv); 137 +} 138 + 139 void 140 destroydecoration(struct wl_listener *listener, void *data) 141 { 142 @@ -1524,6 +1551,83 @@ incnmaster(const Arg *arg) 143 arrange(selmon); 144 } 145 146 +void 147 +incgaps(const Arg *arg) 148 +{ 149 + setgaps( 150 + selmon->gappoh + arg->i, 151 + selmon->gappov + arg->i, 152 + selmon->gappih + arg->i, 153 + selmon->gappiv + arg->i 154 + ); 155 +} 156 + 157 +void 158 +incigaps(const Arg *arg) 159 +{ 160 + setgaps( 161 + selmon->gappoh, 162 + selmon->gappov, 163 + selmon->gappih + arg->i, 164 + selmon->gappiv + arg->i 165 + ); 166 +} 167 + 168 +void 169 +incihgaps(const Arg *arg) 170 +{ 171 + setgaps( 172 + selmon->gappoh, 173 + selmon->gappov, 174 + selmon->gappih + arg->i, 175 + selmon->gappiv 176 + ); 177 +} 178 + 179 +void 180 +incivgaps(const Arg *arg) 181 +{ 182 + setgaps( 183 + selmon->gappoh, 184 + selmon->gappov, 185 + selmon->gappih, 186 + selmon->gappiv + arg->i 187 + ); 188 +} 189 + 190 +void 191 +incogaps(const Arg *arg) 192 +{ 193 + setgaps( 194 + selmon->gappoh + arg->i, 195 + selmon->gappov + arg->i, 196 + selmon->gappih, 197 + selmon->gappiv 198 + ); 199 +} 200 + 201 +void 202 +incohgaps(const Arg *arg) 203 +{ 204 + setgaps( 205 + selmon->gappoh + arg->i, 206 + selmon->gappov, 207 + selmon->gappih, 208 + selmon->gappiv 209 + ); 210 +} 211 + 212 +void 213 +incovgaps(const Arg *arg) 214 +{ 215 + setgaps( 216 + selmon->gappoh, 217 + selmon->gappov + arg->i, 218 + selmon->gappih, 219 + selmon->gappiv 220 + ); 221 +} 222 + 223 void 224 inputdevice(struct wl_listener *listener, void *data) 225 { 226 @@ -2352,6 +2456,16 @@ setgamma(struct wl_listener *listener, void *data) 227 wlr_output_schedule_frame(m->wlr_output); 228 } 229 230 +void 231 +setgaps(int oh, int ov, int ih, int iv) 232 +{ 233 + selmon->gappoh = MAX(oh, 0); 234 + selmon->gappov = MAX(ov, 0); 235 + selmon->gappih = MAX(ih, 0); 236 + selmon->gappiv = MAX(iv, 0); 237 + arrange(selmon); 238 +} 239 + 240 void 241 setlayout(const Arg *arg) 242 { 243 @@ -2691,7 +2805,7 @@ tagmon(const Arg *arg) 244 void 245 tile(Monitor *m) 246 { 247 - unsigned int mw, my, ty; 248 + unsigned int mw, my, ty, h, r, oe = enablegaps, ie = enablegaps; 249 int i, n = 0; 250 Client *c; 251 252 @@ -2701,22 +2815,31 @@ tile(Monitor *m) 253 if (n == 0) 254 return; 255 256 + if (smartgaps == n) { 257 + oe = 0; // outer gaps disabled 258 + } 259 + 260 if (n > m->nmaster) 261 - mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; 262 + mw = m->nmaster ? (int)roundf((m->w.width + m->gappiv*ie) * m->mfact) : 0; 263 else 264 - mw = m->w.width; 265 - i = my = ty = 0; 266 + mw = m->w.width - 2*m->gappov*oe + m->gappiv*ie; 267 + i = 0; 268 + my = ty = m->gappoh*oe; 269 wl_list_for_each(c, &clients, link) { 270 if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) 271 continue; 272 if (i < m->nmaster) { 273 - resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw, 274 - .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0); 275 - my += c->geom.height; 276 + r = MIN(n, m->nmaster) - i; 277 + h = (m->w.height - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; 278 + resize(c, (struct wlr_box){.x = m->w.x + m->gappov*oe, .y = m->w.y + my, 279 + .width = mw - m->gappiv*ie, .height = h}, 0); 280 + my += c->geom.height + m->gappih*ie; 281 } else { 282 - resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty, 283 - .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0); 284 - ty += c->geom.height; 285 + r = n - i; 286 + h = (m->w.height - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; 287 + resize(c, (struct wlr_box){.x = m->w.x + mw + m->gappov*oe, .y = m->w.y + ty, 288 + .width = m->w.width - mw - 2*m->gappov*oe, .height = h}, 0); 289 + ty += c->geom.height + m->gappih*ie; 290 } 291 i++; 292 } 293 @@ -2739,6 +2862,13 @@ togglefullscreen(const Arg *arg) 294 setfullscreen(sel, !sel->isfullscreen); 295 } 296 297 +void 298 +togglegaps(const Arg *arg) 299 +{ 300 + enablegaps = !enablegaps; 301 + arrange(selmon); 302 +} 303 + 304 void 305 toggletag(const Arg *arg) 306 { 307 -- 308 2.46.0 309 310 311 From 8b9db986eddeade22d92fb15a8c836912869be29 Mon Sep 17 00:00:00 2001 312 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= 313 <leohdz172@protonmail.com> 314 Date: Wed, 20 Jul 2022 00:15:32 -0500 315 Subject: [PATCH 2/2] allow gaps in monocle layout if requested 316 MIME-Version: 1.0 317 Content-Type: text/plain; charset=UTF-8 318 Content-Transfer-Encoding: 8bit 319 320 Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me> 321 --- 322 config.def.h | 1 + 323 dwl.c | 6 +++++- 324 2 files changed, 6 insertions(+), 1 deletion(-) 325 326 diff --git a/config.def.h b/config.def.h 327 index 39e528b1..f4d4095d 100644 328 --- a/config.def.h 329 +++ b/config.def.h 330 @@ -7,6 +7,7 @@ 331 static const int sloppyfocus = 1; /* focus follows mouse */ 332 static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ 333 static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ 334 +static const int monoclegaps = 0; /* 1 means outer gaps in monocle layout */ 335 static const unsigned int borderpx = 1; /* border pixel of windows */ 336 static const unsigned int gappih = 10; /* horiz inner gap between windows */ 337 static const unsigned int gappiv = 10; /* vert inner gap between windows */ 338 diff --git a/dwl.c b/dwl.c 339 index d749728a..dbc66ef8 100644 340 --- a/dwl.c 341 +++ b/dwl.c 342 @@ -1879,8 +1879,12 @@ monocle(Monitor *m) 343 wl_list_for_each(c, &clients, link) { 344 if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) 345 continue; 346 - resize(c, m->w, 0); 347 n++; 348 + if (!monoclegaps) 349 + resize(c, m->w, 0); 350 + else 351 + resize(c, (struct wlr_box){.x = m->w.x + gappoh, .y = m->w.y + gappov, 352 + .width = m->w.width - 2 * gappoh, .height = m->w.height - 2 * gappov}, 0); 353 } 354 if (n) 355 snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n); 356 -- 357 2.46.0 358