commit 54664ccb2156cd657a627e557dd205b3793f525c
Author: Mateus Auler <[email protected]>
Date:   Sun Jul 19 18:23:51 2020 -0300

    [dwm][patch][uselessgap] Fixed issue where when moving a client to a 
different monitor, it would incorrectly check the client's previous monitor 
instead of its current one to determine if the gaps and border should be drawn.

diff --git 
a/dwm.suckless.org/patches/uselessgap/dwm-uselessgap-20200719-bb2e722.diff 
b/dwm.suckless.org/patches/uselessgap/dwm-uselessgap-20200719-bb2e722.diff
new file mode 100644
index 00000000..95f06504
--- /dev/null
+++ b/dwm.suckless.org/patches/uselessgap/dwm-uselessgap-20200719-bb2e722.diff
@@ -0,0 +1,83 @@
+From bb3259fd727ae751abb33364e91d73ab1bcda4da Mon Sep 17 00:00:00 2001
+From: Mateus Auler <[email protected]>
+Date: Sun, 19 Jul 2020 18:03:58 -0300
+Subject: [PATCH] Fixed issue where when moving a client to a different
+ monitor, it would incorrectly check the client's previous monitor instead of
+ its current one to determine if the gaps and border should be drawn.
+
+---
+ config.def.h |  1 +
+ dwm.c        | 36 ++++++++++++++++++++++++++++++------
+ 2 files changed, 31 insertions(+), 6 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..b11471d 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,7 @@
+ 
+ /* appearance */
+ static const unsigned int borderpx  = 1;        /* border pixel of windows */
++static const unsigned int gappx     = 6;        /* gaps between windows */
+ static const unsigned int snap      = 32;       /* snap pixel */
+ static const int showbar            = 1;        /* 0 means no bar */
+ static const int topbar             = 1;        /* 0 means bottom bar */
+diff --git a/dwm.c b/dwm.c
+index 9fd0286..79703b3 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -52,8 +52,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)
+ 
+@@ -1277,12 +1277,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);
+-- 
+2.27.0
+
diff --git a/dwm.suckless.org/patches/uselessgap/index.md 
b/dwm.suckless.org/patches/uselessgap/index.md
index 09456137..e73a2a2e 100644
--- a/dwm.suckless.org/patches/uselessgap/index.md
+++ b/dwm.suckless.org/patches/uselessgap/index.md
@@ -47,6 +47,8 @@ tile mode...
 
 Download
 --------
+* [dwm-uselessgap-20200719-bb2e722.diff](dwm-uselessgap-20200719-bb2e722.diff) 
(20200719)
+  Fixed a bug where when moving a client to a different monitor, sometimes the 
gaps and the border wolud be drawn, when they shouldn't.
 * [dwm-uselessgap-6.2.diff](dwm-uselessgap-6.2.diff)
 * [dwm-uselessgap-6.1.diff](dwm-uselessgap-6.1.diff) (4K) (20150815), now 
supports nmaster.
 * [dwm-uselessgap-5.9.diff](dwm-uselessgap-5.9.diff) (1.8k) (20110107 updated. 
Thanks Jordan for your bug report)
@@ -58,3 +60,4 @@ Author
 ------
 * [jerome](http://blog.jardinmagique.info) -  <[email protected]>
 * [Cyril Cressent](https://cressent.org) - <[email protected]> (6.2 port)
+* Mateus Auler - <mateusauler at protonmail dot com> (Bugfix)


Reply via email to