sites

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

dwm-fullgaps-20200508-7b77734.diff (4662B)


      1 From 7b7773458c072e4b24d6ea32d0364a8e402e4a43 Mon Sep 17 00:00:00 2001
      2 From: swy7ch <swy7ch@protonmail.com>
      3 Date: Fri, 8 May 2020 19:07:24 +0200
      4 Subject: [PATCH] [PATCH] update dwm-fullgaps patch to be used with tile layout
      5  update
      6 
      7 the recent tile layout changes in commit HEAD~1 (f09418b) broke the
      8 patch
      9 
     10 this patch adapt the new `if` statements to take gaps into account
     11 
     12 this patch also provides manpage entries for the keybindings
     13 ---
     14  config.def.h |  4 ++++
     15  dwm.1        | 10 ++++++++++
     16  dwm.c        | 33 +++++++++++++++++++++++----------
     17  3 files changed, 37 insertions(+), 10 deletions(-)
     18 
     19 diff --git a/config.def.h b/config.def.h
     20 index 1c0b587..38d2f6c 100644
     21 --- a/config.def.h
     22 +++ b/config.def.h
     23 @@ -2,6 +2,7 @@
     24  
     25  /* appearance */
     26  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     27 +static const unsigned int gappx     = 5;        /* gaps between windows */
     28  static const unsigned int snap      = 32;       /* snap pixel */
     29  static const int showbar            = 1;        /* 0 means no bar */
     30  static const int topbar             = 1;        /* 0 means bottom bar */
     31 @@ -84,6 +85,9 @@ static Key keys[] = {
     32  	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
     33  	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
     34  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     35 +	{ MODKEY,                       XK_minus,  setgaps,        {.i = -1 } },
     36 +	{ MODKEY,                       XK_equal,  setgaps,        {.i = +1 } },
     37 +	{ MODKEY|ShiftMask,             XK_equal,  setgaps,        {.i = 0  } },
     38  	TAGKEYS(                        XK_1,                      0)
     39  	TAGKEYS(                        XK_2,                      1)
     40  	TAGKEYS(                        XK_3,                      2)
     41 diff --git a/dwm.1 b/dwm.1
     42 index 13b3729..0202d96 100644
     43 --- a/dwm.1
     44 +++ b/dwm.1
     45 @@ -140,6 +140,16 @@ View all windows with any tag.
     46  .B Mod1\-Control\-[1..n]
     47  Add/remove all windows with nth tag to/from the view.
     48  .TP
     49 +.B Mod1\--
     50 +Decrease the gaps around windows.
     51 +.TP
     52 +.B Mod1\-=
     53 +Increase the gaps around windows.
     54 +.TP
     55 +.B Mod1\-Shift-=
     56 +Reset the gaps around windows to
     57 +.BR 0 .
     58 +.TP
     59  .B Mod1\-Shift\-q
     60  Quit dwm.
     61  .SS Mouse commands
     62 diff --git a/dwm.c b/dwm.c
     63 index 9fd0286..45a58f3 100644
     64 --- a/dwm.c
     65 +++ b/dwm.c
     66 @@ -119,6 +119,7 @@ struct Monitor {
     67  	int by;               /* bar geometry */
     68  	int mx, my, mw, mh;   /* screen size */
     69  	int wx, wy, ww, wh;   /* window area  */
     70 +	int gappx;            /* gaps between windows */
     71  	unsigned int seltags;
     72  	unsigned int sellt;
     73  	unsigned int tagset[2];
     74 @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
     75  static void setclientstate(Client *c, long state);
     76  static void setfocus(Client *c);
     77  static void setfullscreen(Client *c, int fullscreen);
     78 +static void setgaps(const Arg *arg);
     79  static void setlayout(const Arg *arg);
     80  static void setmfact(const Arg *arg);
     81  static void setup(void);
     82 @@ -639,6 +641,7 @@ createmon(void)
     83  	m->nmaster = nmaster;
     84  	m->showbar = showbar;
     85  	m->topbar = topbar;
     86 +	m->gappx = gappx;
     87  	m->lt[0] = &layouts[0];
     88  	m->lt[1] = &layouts[1 % LENGTH(layouts)];
     89  	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
     90 @@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen)
     91  	}
     92  }
     93  
     94 +void
     95 +setgaps(const Arg *arg)
     96 +{
     97 +	if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
     98 +		selmon->gappx = 0;
     99 +	else
    100 +		selmon->gappx += arg->i;
    101 +	arrange(selmon);
    102 +}
    103 +
    104  void
    105  setlayout(const Arg *arg)
    106  {
    107 @@ -1684,18 +1697,18 @@ tile(Monitor *m)
    108  	if (n > m->nmaster)
    109  		mw = m->nmaster ? m->ww * m->mfact : 0;
    110  	else
    111 -		mw = m->ww;
    112 -	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    113 +		mw = m->ww - m->gappx;
    114 +	for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    115  		if (i < m->nmaster) {
    116 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
    117 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
    118 -			if (my + HEIGHT(c) < m->wh)
    119 -				my += HEIGHT(c);
    120 +			h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
    121 +			resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
    122 +			if (my + HEIGHT(c) + m->gappx < m->wh)
    123 +				my += HEIGHT(c) + m->gappx;
    124  		} else {
    125 -			h = (m->wh - ty) / (n - i);
    126 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
    127 -			if (ty + HEIGHT(c) < m->wh)
    128 -				ty += HEIGHT(c);
    129 +			h = (m->wh - ty) / (n - i) - m->gappx;
    130 +			resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
    131 +			if (ty + HEIGHT(c) + m->gappx < m->wh)
    132 +				ty += HEIGHT(c) + m->gappx;
    133  		}
    134  }
    135  
    136 -- 
    137 2.26.2
    138