dwm-uselessgap-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-uselessgap-6.2.diff (2784B)
---
1 From 58a5ece9406ca6c90dc362617c065e4aac19417f Mon Sep 17 00:00:00 2001
2 From: Cyril Cressent <cyril@cressent.org>
3 Date: Wed, 3 Jul 2019 21:33:45 -0700
4 Subject: [PATCH] Port the uselessgap patch to 6.2
5
6 ---
7 config.def.h | 1 +
8 dwm.c | 36 ++++++++++++++++++++++++++++++------
9 2 files changed, 31 insertions(+), 6 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 1c0b587..b11471d 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -2,6 +2,7 @@
16
17 /* appearance */
18 static const unsigned int borderpx = 1; /* border pixel of windows */
19 +static const unsigned int gappx = 6; /* gaps between windows */
20 static const unsigned int snap = 32; /* snap pixel */
21 static const int showbar = 1; /* 0 means no bar */
22 static const int topbar = 1; /* 0 means bottom bar */
23 diff --git a/dwm.c b/dwm.c
24 index 4465af1..4545e05 100644
25 --- a/dwm.c
26 +++ b/dwm.c
27 @@ -52,8 +52,8 @@
28 #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
29 #define LENGTH(X) (sizeof X / sizeof X[0])
30 #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
31 -#define WIDTH(X) ((X)->w + 2 * (X)->bw)
32 -#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
33 +#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
34 +#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
35 #define TAGMASK ((1 << LENGTH(tags)) - 1)
36 #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
37
38 @@ -1276,12 +1276,36 @@ void
39 resizeclient(Client *c, int x, int y, int w, int h)
40 {
41 XWindowChanges wc;
42 + unsigned int n;
43 + unsigned int gapoffset;
44 + unsigned int gapincr;
45 + Client *nbc;
46
47 - c->oldx = c->x; c->x = wc.x = x;
48 - c->oldy = c->y; c->y = wc.y = y;
49 - c->oldw = c->w; c->w = wc.width = w;
50 - c->oldh = c->h; c->h = wc.height = h;
51 wc.border_width = c->bw;
52 +
53 + /* Get number of clients for the selected monitor */
54 + for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++);
55 +
56 + /* Do nothing if layout is floating */
57 + if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) {
58 + gapincr = gapoffset = 0;
59 + } else {
60 + /* Remove border and gap if layout is monocle or only one client */
61 + if (selmon->lt[selmon->sellt]->arrange == monocle || n == 1) {
62 + gapoffset = 0;
63 + gapincr = -2 * borderpx;
64 + wc.border_width = 0;
65 + } else {
66 + gapoffset = gappx;
67 + gapincr = 2 * gappx;
68 + }
69 + }
70 +
71 + c->oldx = c->x; c->x = wc.x = x + gapoffset;
72 + c->oldy = c->y; c->y = wc.y = y + gapoffset;
73 + c->oldw = c->w; c->w = wc.width = w - gapincr;
74 + c->oldh = c->h; c->h = wc.height = h - gapincr;
75 +
76 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
77 configure(c);
78 XSync(dpy, False);
79 --
80 2.22.0
81