aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--config.def.h1
-rw-r--r--dwm.c36
3 files changed, 33 insertions, 6 deletions
diff --git a/README.md b/README.md
index ba13cb6..8b5a393 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,10 @@ This is my fork of [dwm][dwm], with following patches applied:
- [statuscmd][statuscmd]
- [xresources][xresources]
- [autostart][autostart]
+- [useless gap][useless gap]
[dwm]: https://dwm.suckless.org
[statuscmd]: https://dwm.suckless.org/patches/statuscmd/dwm-statuscmd-20210405-67d76bd.diff
[xresources]: https://dwm.suckless.org/patches/xresources/dwm-xresources-20210314.diff
[autostart]: https://dwm.suckless.org/patches/autostart/dwm-autostart-20210120-cb3f58a.diff
+[useless gap]: https://dwm.suckless.org/patches/uselessgap/dwm-uselessgap-20200719-bb2e722.diff
diff --git a/config.def.h b/config.def.h
index 7f7cbbf..932e9e7 100644
--- a/config.def.h
+++ b/config.def.h
@@ -2,6 +2,7 @@
/* appearance */
static unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int gappx = 6; /* gaps between windows */
static unsigned int snap = 32; /* snap pixel */
static int showbar = 1; /* 0 means no bar */
static int topbar = 1; /* 0 means bottom bar */
diff --git a/dwm.c b/dwm.c
index a9d6b3d..891fae8 100644
--- a/dwm.c
+++ b/dwm.c
@@ -54,8 +54,8 @@
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
-#define WIDTH(X) ((X)->w + 2 * (X)->bw)
-#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
+#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx)
+#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
@@ -1358,12 +1358,36 @@ void
resizeclient(Client *c, int x, int y, int w, int h)
{
XWindowChanges wc;
+ unsigned int n;
+ unsigned int gapoffset;
+ unsigned int gapincr;
+ Client *nbc;
- c->oldx = c->x; c->x = wc.x = x;
- c->oldy = c->y; c->y = wc.y = y;
- c->oldw = c->w; c->w = wc.width = w;
- c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+
+ /* Get number of clients for the client's monitor */
+ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
+
+ /* Do nothing if layout is floating */
+ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
+ gapincr = gapoffset = 0;
+ } else {
+ /* Remove border and gap if layout is monocle or only one client */
+ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
+ gapoffset = 0;
+ gapincr = -2 * borderpx;
+ wc.border_width = 0;
+ } else {
+ gapoffset = gappx;
+ gapincr = 2 * gappx;
+ }
+ }
+
+ c->oldx = c->x; c->x = wc.x = x + gapoffset;
+ c->oldy = c->y; c->y = wc.y = y + gapoffset;
+ c->oldw = c->w; c->w = wc.width = w - gapincr;
+ c->oldh = c->h; c->h = wc.height = h - gapincr;
+
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);