sites

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

dwm-tilegap-6.2.diff (2538B)


      1 From dfea960240ed45a660abc1acba2041318127761f Mon Sep 17 00:00:00 2001
      2 From: astier <aleksandrs.stier@uni-bielefeld.de>
      3 Date: Thu, 21 Feb 2019 09:38:38 +0100
      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  config.def.h |  1 +
     13  dwm.c        | 23 +++++++++++++----------
     14  2 files changed, 14 insertions(+), 10 deletions(-)
     15 
     16 diff --git a/config.def.h b/config.def.h
     17 index 1c0b587..2ca9e56 100644
     18 --- a/config.def.h
     19 +++ b/config.def.h
     20 @@ -2,6 +2,7 @@
     21  
     22  /* appearance */
     23  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     24 +static const unsigned int gappx     = 18;       /* gap pixel between windows */
     25  static const unsigned int snap      = 32;       /* snap pixel */
     26  static const int showbar            = 1;        /* 0 means no bar */
     27  static const int topbar             = 1;        /* 0 means bottom bar */
     28 diff --git a/dwm.c b/dwm.c
     29 index 4465af1..c556a2d 100644
     30 --- a/dwm.c
     31 +++ b/dwm.c
     32 @@ -1673,26 +1673,29 @@ tagmon(const Arg *arg)
     33  void
     34  tile(Monitor *m)
     35  {
     36 -	unsigned int i, n, h, mw, my, ty;
     37 +	unsigned int i, n, h, mw, my, ty, ns;
     38  	Client *c;
     39  
     40  	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     41  	if (n == 0)
     42  		return;
     43  
     44 -	if (n > m->nmaster)
     45 +	if (n > m->nmaster) {
     46  		mw = m->nmaster ? m->ww * m->mfact : 0;
     47 -	else
     48 +		ns = m->nmaster > 0 ? 2 : 1;
     49 +	} else {
     50  		mw = m->ww;
     51 -	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     52 +		ns = 1;
     53 +	}
     54 +	for(i = 0, my = ty = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     55  		if (i < m->nmaster) {
     56 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     57 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     58 -			my += HEIGHT(c);
     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 +			my += HEIGHT(c) + gappx;
     62  		} else {
     63 -			h = (m->wh - ty) / (n - i);
     64 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     65 -			ty += HEIGHT(c);
     66 +			h = (m->wh - ty) / (n - i) - gappx;
     67 +			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);
     68 +			ty += HEIGHT(c) + gappx;
     69  		}
     70  }
     71  
     72 -- 
     73 2.20.1