sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-uselessgap-20200719-bb2e722.diff (2960B)


      1 From bb3259fd727ae751abb33364e91d73ab1bcda4da Mon Sep 17 00:00:00 2001
      2 From: Mateus Auler <mateusauler@protonmail.com>
      3 Date: Sun, 19 Jul 2020 18:03:58 -0300
      4 Subject: [PATCH] Fixed issue where when moving a client to a different
      5  monitor, it would incorrectly check the client's previous monitor instead of
      6  its current one to determine if the gaps and border should be drawn.
      7 
      8 ---
      9  config.def.h |  1 +
     10  dwm.c        | 36 ++++++++++++++++++++++++++++++------
     11  2 files changed, 31 insertions(+), 6 deletions(-)
     12 
     13 diff --git a/config.def.h b/config.def.h
     14 index 1c0b587..b11471d 100644
     15 --- a/config.def.h
     16 +++ b/config.def.h
     17 @@ -2,6 +2,7 @@
     18  
     19  /* appearance */
     20  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     21 +static const unsigned int gappx     = 6;        /* gaps between windows */
     22  static const unsigned int snap      = 32;       /* snap pixel */
     23  static const int showbar            = 1;        /* 0 means no bar */
     24  static const int topbar             = 1;        /* 0 means bottom bar */
     25 diff --git a/dwm.c b/dwm.c
     26 index 9fd0286..79703b3 100644
     27 --- a/dwm.c
     28 +++ b/dwm.c
     29 @@ -52,8 +52,8 @@
     30  #define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
     31  #define LENGTH(X)               (sizeof X / sizeof X[0])
     32  #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
     33 -#define WIDTH(X)                ((X)->w + 2 * (X)->bw)
     34 -#define HEIGHT(X)               ((X)->h + 2 * (X)->bw)
     35 +#define WIDTH(X)                ((X)->w + 2 * (X)->bw + gappx)
     36 +#define HEIGHT(X)               ((X)->h + 2 * (X)->bw + gappx)
     37  #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
     38  #define TEXTW(X)                (drw_fontset_getwidth(drw, (X)) + lrpad)
     39  
     40 @@ -1277,12 +1277,36 @@ void
     41  resizeclient(Client *c, int x, int y, int w, int h)
     42  {
     43  	XWindowChanges wc;
     44 +	unsigned int n;
     45 +	unsigned int gapoffset;
     46 +	unsigned int gapincr;
     47 +	Client *nbc;
     48  
     49 -	c->oldx = c->x; c->x = wc.x = x;
     50 -	c->oldy = c->y; c->y = wc.y = y;
     51 -	c->oldw = c->w; c->w = wc.width = w;
     52 -	c->oldh = c->h; c->h = wc.height = h;
     53  	wc.border_width = c->bw;
     54 +
     55 +	/* Get number of clients for the client's monitor */
     56 +	for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
     57 +
     58 +	/* Do nothing if layout is floating */
     59 +	if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
     60 +		gapincr = gapoffset = 0;
     61 +	} else {
     62 +		/* Remove border and gap if layout is monocle or only one client */
     63 +		if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
     64 +			gapoffset = 0;
     65 +			gapincr = -2 * borderpx;
     66 +			wc.border_width = 0;
     67 +		} else {
     68 +			gapoffset = gappx;
     69 +			gapincr = 2 * gappx;
     70 +		}
     71 +	}
     72 +
     73 +	c->oldx = c->x; c->x = wc.x = x + gapoffset;
     74 +	c->oldy = c->y; c->y = wc.y = y + gapoffset;
     75 +	c->oldw = c->w; c->w = wc.width = w - gapincr;
     76 +	c->oldh = c->h; c->h = wc.height = h - gapincr;
     77 +
     78  	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
     79  	configure(c);
     80  	XSync(dpy, False);
     81 -- 
     82 2.27.0
     83