sites

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

dwm-fullgaps-6.4.diff (3653B)


      1 diff -up a/config.def.h b/config.def.h
      2 --- a/config.def.h
      3 +++ b/config.def.h
      4 @@ -2,6 +2,7 @@
      5  
      6  /* appearance */
      7  static const unsigned int borderpx  = 1;        /* border pixel of windows */
      8 +static const unsigned int gappx     = 5;        /* gaps between windows */
      9  static const unsigned int snap      = 32;       /* snap pixel */
     10  static const int showbar            = 1;        /* 0 means no bar */
     11  static const int topbar             = 1;        /* 0 means bottom bar */
     12 @@ -85,6 +86,9 @@ static const Key keys[] = {
     13  	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
     14  	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
     15  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     16 +	{ MODKEY,                       XK_minus,  setgaps,        {.i = -1 } },
     17 +	{ MODKEY,                       XK_equal,  setgaps,        {.i = +1 } },
     18 +	{ MODKEY|ShiftMask,             XK_equal,  setgaps,        {.i = 0  } },
     19  	TAGKEYS(                        XK_1,                      0)
     20  	TAGKEYS(                        XK_2,                      1)
     21  	TAGKEYS(                        XK_3,                      2)
     22 diff -up a/dwm.c b/dwm.c
     23 --- a/dwm.c	2023-04-30
     24 +++ b/dwm.c	2023-04-30
     25 @@ -119,6 +119,7 @@ struct Monitor {
     26  	int by;               /* bar geometry */
     27  	int mx, my, mw, mh;   /* screen size */
     28  	int wx, wy, ww, wh;   /* window area  */
     29 +	int gappx;            /* gaps between windows */
     30  	unsigned int seltags;
     31  	unsigned int sellt;
     32  	unsigned int tagset[2];
     33 @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *
     34  static void setclientstate(Client *c, long state);
     35  static void setfocus(Client *c);
     36  static void setfullscreen(Client *c, int fullscreen);
     37 +static void setgaps(const Arg *arg);
     38  static void setlayout(const Arg *arg);
     39  static void setmfact(const Arg *arg);
     40  static void setup(void);
     41 @@ -641,6 +643,7 @@ createmon(void)
     42  	m->nmaster = nmaster;
     43  	m->showbar = showbar;
     44  	m->topbar = topbar;
     45 +	m->gappx = gappx;
     46  	m->lt[0] = &layouts[0];
     47  	m->lt[1] = &layouts[1 % LENGTH(layouts)];
     48  	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
     49 @@ -1508,6 +1511,16 @@ setfullscreen(Client *c, int fullscreen)
     50  }
     51  
     52  void
     53 +setgaps(const Arg *arg)
     54 +{
     55 +	if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
     56 +		selmon->gappx = 0;
     57 +	else
     58 +		selmon->gappx += arg->i;
     59 +	arrange(selmon);
     60 +}
     61 +
     62 +void
     63  setlayout(const Arg *arg)
     64  {
     65  	if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
     66 @@ -1697,18 +1710,18 @@ tile(Monitor *m)
     67  	if (n > m->nmaster)
     68  		mw = m->nmaster ? m->ww * m->mfact : 0;
     69  	else
     70 -		mw = m->ww;
     71 -	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     72 -		if (i < m->nmaster) {
     73 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
     74 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
     75 -			if (my + HEIGHT(c) < m->wh)
     76 -				my += HEIGHT(c);
     77 +		mw = m->ww - m->gappx;
     78 +	for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     79 +			if (i < m->nmaster) {
     80 +			h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
     81 +			resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
     82 +			if (my + HEIGHT(c) + m->gappx < m->wh)
     83 +				my += HEIGHT(c) + m->gappx;
     84  		} else {
     85 -			h = (m->wh - ty) / (n - i);
     86 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
     87 -			if (ty + HEIGHT(c) < m->wh)
     88 -				ty += HEIGHT(c);
     89 +			h = (m->wh - ty) / (n - i) - m->gappx;
     90 +			resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
     91 +			if (ty + HEIGHT(c) + m->gappx < m->wh)
     92 +				ty += HEIGHT(c) + m->gappx;
     93  		}
     94  }