sites

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

dwm-tilegap-6.4.diff (2597B)


      1 From e655302a4bd74c1f2778f94761c87381d1dfc0e2 Mon Sep 17 00:00:00 2001
      2 From: midspec <obleque@protonmail.com>
      3 Date: Sat, 4 Nov 2023 19:17:50 +0000
      4 Subject: [PATCH] Add window-gaps for the tile-layout
      5 
      6 Adds gaps between windows in the tile-layout. The proposed advantage to some
      7 other patches which try to accomplish the same goal is that the gap-size between
      8 master and stack, window and window, and window and screen-edge is the
      9 same. The gap-size can be configured in the config.h with the
     10 gappx-variable.
     11 
     12 ---
     13  config.def.h |  1 +
     14  dwm.c        | 23 +++++++++++++----------
     15  2 files changed, 14 insertions(+), 10 deletions(-)
     16 
     17 diff --git a/config.def.h b/config.def.h
     18 index 9efa774..82ba41f 100644
     19 --- a/config.def.h
     20 +++ b/config.def.h
     21 @@ -2,6 +2,7 @@
     22  
     23  /* appearance */
     24  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     25 +static const unsigned int gappx     = 18;       /* gap pixel between windows */
     26  static const unsigned int snap      = 32;       /* snap pixel */
     27  static const int showbar            = 1;        /* 0 means no bar */
     28  static const int topbar             = 1;        /* 0 means bottom bar */
     29 diff --git a/dwm.c b/dwm.c
     30 index f1d86b2..fa8b3d6 100644
     31 --- a/dwm.c
     32 +++ b/dwm.c
     33 @@ -1687,28 +1687,31 @@ tagmon(const Arg *arg)
     34  void
     35  tile(Monitor *m)
     36  {
     37 -	unsigned int i, n, h, mw, my, ty;
     38 +	unsigned int i, n, h, mw, my, ty, ns;
     39  	Client *c;
     40  
     41  	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     42  	if (n == 0)
     43  		return;
     44  
     45 -	if (n > m->nmaster)
     46 +	if (n > m->nmaster) {
     47  		mw = m->nmaster ? m->ww * m->mfact : 0;
     48 -	else
     49 +		ns = m->nmaster > 0 ? 2 : 1;
     50 +	} else {
     51  		mw = m->ww;
     52 -	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     53 +		ns = 1;
     54 +	}
     55 +	for(i = 0, my = ty = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     56  		if (i < m->nmaster) {
     57 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     58 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     59 +			h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx;
     60 +			resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False);
     61  			if (my + HEIGHT(c) < m->wh)
     62 -				my += HEIGHT(c);
     63 +				my += HEIGHT(c) + gappx;
     64  		} else {
     65 -			h = (m->wh - ty) / (n - i);
     66 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     67 +			h = (m->wh - ty) / (n - i) - gappx;
     68 +			resize(c, m->wx + mw + gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False);
     69  			if (ty + HEIGHT(c) < m->wh)
     70 -				ty += HEIGHT(c);
     71 +				ty += HEIGHT(c) + gappx;
     72  		}
     73  }
     74  
     75 -- 
     76 2.42.0
     77