sites

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

dwm-ru_gaps-6.2.diff (4543B)


      1 diff -up a/config.def.h b/config.def.h
      2 --- a/config.def.h	2019-07-21 22:43:04.535873031 +0200
      3 +++ b/config.def.h	2019-07-24 08:48:08.038433535 +0200
      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 @@ -84,6 +85,9 @@ static 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 = -5 } },
     17 +	{ MODKEY,                       XK_equal,  setgaps,        {.i = +5 } },
     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	2019-07-21 22:43:04.535873031 +0200
     24 +++ b/dwm.c	2019-07-24 08:50:44.989360476 +0200
     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 @@ -199,6 +200,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 @@ -638,6 +640,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 @@ -1282,6 +1285,13 @@ resizeclient(Client *c, int x, int y, in
     50  	c->oldw = c->w; c->w = wc.width = w;
     51  	c->oldh = c->h; c->h = wc.height = h;
     52  	wc.border_width = c->bw;
     53 +	if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
     54 +	    || &monocle == c->mon->lt[c->mon->sellt]->arrange))
     55 +	{
     56 +		c->w = wc.width += c->bw * 2;
     57 +		c->h = wc.height += c->bw * 2;
     58 +		wc.border_width = 0;
     59 +	}
     60  	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
     61  	configure(c);
     62  	XSync(dpy, False);
     63 @@ -1498,6 +1508,16 @@ setfullscreen(Client *c, int fullscreen)
     64  }
     65  
     66  void
     67 +setgaps(const Arg *arg)
     68 +{
     69 +	if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
     70 +		selmon->gappx = 0;
     71 +	else
     72 +		selmon->gappx += arg->i;
     73 +	arrange(selmon);
     74 +}
     75 +
     76 +void
     77  setlayout(const Arg *arg)
     78  {
     79  	if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
     80 @@ -1673,26 +1693,35 @@ tagmon(const Arg *arg)
     81  void
     82  tile(Monitor *m)
     83  {
     84 -	unsigned int i, n, h, mw, my, ty;
     85 +	unsigned int i, n, h, mw, my, ty, ns;
     86  	Client *c;
     87  
     88  	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     89  	if (n == 0)
     90  		return;
     91 +	if(n == 1){
     92 +		c = nexttiled(m->clients);
     93 +		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
     94 +		return;
     95 +	}
     96  
     97 -	if (n > m->nmaster)
     98 +	if (n > m->nmaster){
     99  		mw = m->nmaster ? m->ww * m->mfact : 0;
    100 -	else
    101 -		mw = m->ww;
    102 -	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    103 +		ns = m->nmaster > 0 ? 2 : 1;
    104 +	}
    105 +	else{
    106 +		mw = m->ww - m->gappx;
    107 +		ns = 1;
    108 +	}
    109 +	for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    110  		if (i < m->nmaster) {
    111 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
    112 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
    113 -			my += HEIGHT(c);
    114 +			h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
    115 +			resize(c, m->wx + m->gappx, m->wy + my, mw - 2*c->bw - m->gappx*(5-ns)/2, h - 2*c->bw, 0);
    116 +			my += HEIGHT(c) + m->gappx;
    117  		} else {
    118 -			h = (m->wh - ty) / (n - i);
    119 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
    120 -			ty += HEIGHT(c);
    121 +			h = (m->wh - ty) / (n - i) - m->gappx;
    122 +			resize(c, m->wx + mw + m->gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, h - 2*c->bw, 0);
    123 +			ty += HEIGHT(c) + m->gappx;
    124  		}
    125  }