dwm-uselessgap-20211119-58414bee958f2.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-uselessgap-20211119-58414bee958f2.diff (3798B)
       ---
            1 From 58414bee958f2e7ed91d6fe31f503ec4a406981b Mon Sep 17 00:00:00 2001
            2 From: cirala <thim@cederlund.de>
            3 Date: Fri, 19 Nov 2021 18:14:07 +0100
            4 Subject: [PATCH] Fix for dwm-uselessgap
            5 Previous versions of the patch doubles the
            6 gap between the master and slave stacks.
            7 
            8 ---
            9  config.def.h |  3 ++-
           10  dwm.c        | 38 +++++++++++++++++++++++++++++++-------
           11  2 files changed, 33 insertions(+), 8 deletions(-)
           12 
           13 diff --git a/config.def.h b/config.def.h
           14 index a2ac963..17a205f 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 @@ -34,7 +35,7 @@ static const Rule rules[] = {
           26  /* layout(s) */
           27  static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
           28  static const int nmaster     = 1;    /* number of clients in master area */
           29 -static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
           30 +static const int resizehints = 0;    /* 1 means respect size hints in tiled resizals */
           31  static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
           32 
           33  static const Layout layouts[] = {
           34 diff --git a/dwm.c b/dwm.c
           35 index 5e4d494..b626e89 100644
           36 --- a/dwm.c
           37 +++ b/dwm.c
           38 @@ -52,8 +52,8 @@
           39  #define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
           40  #define LENGTH(X)               (sizeof X / sizeof X[0])
           41  #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
           42 -#define WIDTH(X)                ((X)->w + 2 * (X)->bw)
           43 -#define HEIGHT(X)               ((X)->h + 2 * (X)->bw)
           44 +#define WIDTH(X)                ((X)->w + 2 * (X)->bw + gappx)
           45 +#define HEIGHT(X)               ((X)->h + 2 * (X)->bw + gappx)
           46  #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
           47  #define TEXTW(X)                (drw_fontset_getwidth(drw, (X)) + lrpad)
           48 
           49 @@ -1277,12 +1277,36 @@ void
           50  resizeclient(Client *c, int x, int y, int w, int h)
           51  {
           52          XWindowChanges wc;
           53 +        unsigned int n;
           54 +        unsigned int gapoffset;
           55 +        unsigned int gapincr;
           56 +        Client *nbc;
           57 
           58 -        c->oldx = c->x; c->x = wc.x = x;
           59 -        c->oldy = c->y; c->y = wc.y = y;
           60 -        c->oldw = c->w; c->w = wc.width = w;
           61 -        c->oldh = c->h; c->h = wc.height = h;
           62          wc.border_width = c->bw;
           63 +
           64 +        /* Get number of clients for the client's monitor */
           65 +        for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
           66 +
           67 +        /* Do nothing if layout is floating */
           68 +        if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
           69 +                gapincr = gapoffset = 0;
           70 +        } else {
           71 +                /* Remove border and gap if layout is monocle or only one client */
           72 +                if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
           73 +                        gapoffset = 0;
           74 +                        gapincr = -2 * borderpx;
           75 +                        wc.border_width = 0;
           76 +                } else {
           77 +                        gapoffset = gappx;
           78 +                        gapincr = 2 * gappx;
           79 +                }
           80 +        }
           81 +
           82 +        c->oldx = c->x; c->x = wc.x = x + gapoffset;
           83 +        c->oldy = c->y; c->y = wc.y = y + gapoffset;
           84 +        c->oldw = c->w; c->w = wc.width = w - gapincr;
           85 +        c->oldh = c->h; c->h = wc.height = h - gapincr;
           86 +
           87          XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
           88          configure(c);
           89          XSync(dpy, False);
           90 @@ -1688,7 +1712,7 @@ tile(Monitor *m)
           91          for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
           92                  if (i < m->nmaster) {
           93                          h = (m->wh - my) / (MIN(n, m->nmaster) - i);
           94 -                        resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
           95 +                        resize(c, m->wx, m->wy + my, mw - (2*c->bw) + (n > 1 ? gappx : 0), h - (2*c->bw), 0);
           96                          if (my + HEIGHT(c) < m->wh)
           97                                  my += HEIGHT(c);
           98                  } else {
           99 --
          100 2.33.1
          101