sites

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

dwm-functionalgaps-pertagfunctionality-6.2.diff (9343B)


      1 diff -pu dwm.withpertag/config.def.h dwm.functionalgapspertag/config.def.h
      2 --- dwm.withpertag/config.def.h	2021-02-27 23:47:22.426092186 -0600
      3 +++ dwm.functionalgapspertag/config.def.h	2021-03-01 15:40:07.312696974 -0600
      4 @@ -2,6 +2,8 @@
      5  
      6  /* appearance */
      7  static const unsigned int borderpx  = 1;        /* border pixel of windows */
      8 +static const int startwithgaps[]    = { 0 };	/* 1 means gaps are used by default, this can be customized for each tag */
      9 +static const unsigned int gappx[]   = { 10 };   /* default gap between windows in pixels, this can be customized for each tag */
     10  static const unsigned int snap      = 32;       /* snap pixel */
     11  static const int showbar            = 1;        /* 0 means no bar */
     12  static const int topbar             = 1;        /* 0 means bottom bar */
     13 @@ -84,6 +86,10 @@ static Key keys[] = {
     14  	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
     15  	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
     16  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     17 +	{ MODKEY,                       XK_minus,  setgaps,        {.i = -5 } },
     18 +	{ MODKEY,                       XK_equal,  setgaps,        {.i = +5 } },
     19 +	{ MODKEY|ShiftMask,             XK_minus,  setgaps,        {.i = GAP_RESET } },
     20 +	{ MODKEY|ShiftMask,             XK_equal,  setgaps,        {.i = GAP_TOGGLE} },
     21  	TAGKEYS(                        XK_1,                      0)
     22  	TAGKEYS(                        XK_2,                      1)
     23  	TAGKEYS(                        XK_3,                      2)
     24 diff -pu dwm.withpertag/dwm.c dwm.functionalgapspertag/dwm.c
     25 --- dwm.withpertag/dwm.c	2021-02-27 23:47:41.352759785 -0600
     26 +++ dwm.functionalgapspertag/dwm.c	2021-03-01 17:10:10.402964866 -0600
     27 @@ -57,6 +57,9 @@
     28  #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
     29  #define TEXTW(X)                (drw_fontset_getwidth(drw, (X)) + lrpad)
     30  
     31 +#define GAP_TOGGLE 100
     32 +#define GAP_RESET  0
     33 +
     34  /* enums */
     35  enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
     36  enum { SchemeNorm, SchemeSel }; /* color schemes */
     37 @@ -112,6 +115,7 @@ typedef struct {
     38  } Layout;
     39  
     40  typedef struct Pertag Pertag;
     41 +
     42  struct Monitor {
     43  	char ltsymbol[16];
     44  	float mfact;
     45 @@ -202,6 +206,7 @@ static void sendmon(Client *c, Monitor *
     46  static void setclientstate(Client *c, long state);
     47  static void setfocus(Client *c);
     48  static void setfullscreen(Client *c, int fullscreen);
     49 +static void setgaps(const Arg *arg);
     50  static void setlayout(const Arg *arg);
     51  static void setmfact(const Arg *arg);
     52  static void setup(void);
     53 @@ -281,6 +286,9 @@ struct Pertag {
     54  	unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
     55  	const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes  */
     56  	int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
     57 +
     58 +	int drawwithgaps[LENGTH(tags) + 1]; /* gaps toggle for each tag */
     59 +	int gappx[LENGTH(tags) + 1]; /* gaps for each tag */
     60  };
     61  
     62  /* compile-time check if all tags fit into an unsigned int bit array. */
     63 @@ -666,7 +674,13 @@ createmon(void)
     64  		m->pertag->sellts[i] = m->sellt;
     65  
     66  		m->pertag->showbars[i] = m->showbar;
     67 +		if (i > 0) {
     68 +			m->pertag->drawwithgaps[i] = startwithgaps[(i - 1) % LENGTH(gappx)];
     69 +			m->pertag->gappx[i] = gappx[(i - 1) % LENGTH(gappx)];
     70 +		}
     71  	}
     72 +	m->pertag->drawwithgaps[0] = startwithgaps[0]; 
     73 +	m->pertag->gappx[0] = gappx[0];
     74  
     75  	return m;
     76  }
     77 @@ -823,6 +837,12 @@ focus(Client *c)
     78  		attachstack(c);
     79  		grabbuttons(c, 1);
     80  		XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
     81 +                if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && !c->isfloating) {
     82 +			XWindowChanges wc;
     83 +                        wc.sibling = selmon->barwin;
     84 +                        wc.stack_mode = Below;
     85 +                        XConfigureWindow(dpy, c->win, CWSibling | CWStackMode, &wc);
     86 +                }
     87  		setfocus(c);
     88  	} else {
     89  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
     90 @@ -1139,7 +1159,10 @@ monocle(Monitor *m)
     91  	if (n > 0) /* override layout symbol */
     92  		snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
     93  	for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
     94 -		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
     95 +		if (selmon->pertag->drawwithgaps[selmon->pertag->curtag])
     96 +			resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
     97 +		else
     98 +			resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
     99  }
    100  
    101  void
    102 @@ -1309,6 +1332,15 @@ resizeclient(Client *c, int x, int y, in
    103  	c->oldw = c->w; c->w = wc.width = w;
    104  	c->oldh = c->h; c->h = wc.height = h;
    105  	wc.border_width = c->bw;
    106 +	if (!selmon->pertag->drawwithgaps[selmon->pertag->curtag] && /* this is the noborderfloatingfix patch, slightly modified so that it will work if, and only if, gaps are disabled. */
    107 +	    (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) /* these two first lines are the only ones changed. if you are manually patching and have noborder installed already, just change these lines; or conversely, just remove this section if the noborder patch is not desired;) */
    108 +	    || &monocle == c->mon->lt[c->mon->sellt]->arrange))
    109 +	    && !c->isfullscreen && !c->isfloating
    110 +	    && NULL != c->mon->lt[c->mon->sellt]->arrange) {
    111 +	        c->w = wc.width += c->bw * 2;
    112 +	        c->h = wc.height += c->bw * 2;
    113 +	        wc.border_width = 0;
    114 +	}
    115  	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
    116  	configure(c);
    117  	XSync(dpy, False);
    118 @@ -1525,6 +1557,29 @@ setfullscreen(Client *c, int fullscreen)
    119  }
    120  
    121  void
    122 +setgaps(const Arg *arg)
    123 +{
    124 +	switch(arg->i)
    125 +	{
    126 +		case GAP_TOGGLE:
    127 +			selmon->pertag->drawwithgaps[selmon->pertag->curtag] = !selmon->pertag->drawwithgaps[selmon->pertag->curtag];
    128 +			break;
    129 +		case GAP_RESET:
    130 +			if (selmon->pertag->curtag > 0)
    131 +				selmon->pertag->gappx[selmon->pertag->curtag] = gappx[selmon->pertag->curtag - 1 % LENGTH(gappx)];
    132 +			else
    133 +				selmon->pertag->gappx[0] = gappx[0];
    134 +			break;
    135 +		default:
    136 +			if (selmon->pertag->gappx[selmon->pertag->curtag] + arg->i < 0)
    137 +				selmon->pertag->gappx[selmon->pertag->curtag] = 0;
    138 +			else
    139 +				selmon->pertag->gappx[selmon->pertag->curtag] += arg->i;
    140 +	}
    141 +	arrange(selmon);
    142 +}
    143 +
    144 +void
    145  setlayout(const Arg *arg)
    146  {
    147  	if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
    148 @@ -1706,23 +1761,42 @@ tile(Monitor *m)
    149  	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    150  	if (n == 0)
    151  		return;
    152 -
    153 -	if (n > m->nmaster)
    154 -		mw = m->nmaster ? m->ww * m->mfact : 0;
    155 -	else
    156 -		mw = m->ww;
    157 -	for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    158 -		if (i < m->nmaster) {
    159 -			h = (m->wh - my) / (MIN(n, m->nmaster) - i);
    160 -			resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
    161 -			if (my + HEIGHT(c) < m->wh)
    162 -				my += HEIGHT(c);
    163 -		} else {
    164 -			h = (m->wh - ty) / (n - i);
    165 -			resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
    166 -			if (ty + HEIGHT(c) < m->wh)
    167 -				ty += HEIGHT(c);
    168 -		}
    169 +	if (m->pertag->drawwithgaps[m->pertag->curtag]) { /* draw with fullgaps logic */
    170 +	        if (n > m->nmaster)
    171 +	                mw = m->nmaster ? m->ww * m->mfact : 0;
    172 +	        else
    173 +	                mw = m->ww - m->pertag->gappx[m->pertag->curtag];
    174 +	        for (i = 0, my = ty = m->pertag->gappx[m->pertag->curtag], c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    175 +	                if (i < m->nmaster) {
    176 +	                        h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->pertag->gappx[m->pertag->curtag];
    177 +	                        resize(c, m->wx + m->pertag->gappx[m->pertag->curtag], m->wy + my, mw - (2*c->bw) - m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
    178 +	                        if (my + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
    179 +	                                my += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
    180 +	                } else {
    181 +	                        h = (m->wh - ty) / (n - i) - m->pertag->gappx[m->pertag->curtag];
    182 +	                        resize(c, m->wx + mw + m->pertag->gappx[m->pertag->curtag], m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->pertag->gappx[m->pertag->curtag], h - (2*c->bw), 0);
    183 +	                        if (ty + HEIGHT(c) + m->pertag->gappx[m->pertag->curtag] < m->wh)
    184 +	                                ty += HEIGHT(c) + m->pertag->gappx[m->pertag->curtag];
    185 +	                }
    186 +	} else { /* draw with singularborders logic */
    187 +	        if (n > m->nmaster)
    188 +	                mw = m->nmaster ? m->ww * m->mfact : 0;
    189 +	        else
    190 +	                mw = m->ww;
    191 +	        for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
    192 +	                if (i < m->nmaster) {
    193 +	                        h = (m->wh - my) / (MIN(n, m->nmaster) - i);
    194 +	                        if (n == 1)
    195 +	                                resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
    196 +	                        else
    197 +	                                resize(c, m->wx - c->bw, m->wy + my, mw - c->bw, h - c->bw, False);
    198 +	                        my += HEIGHT(c) - c->bw;
    199 +	                } else {
    200 +	                        h = (m->wh - ty) / (n - i);
    201 +	                        resize(c, m->wx + mw - c->bw, m->wy + ty, m->ww - mw, h - c->bw, False);
    202 +	                        ty += HEIGHT(c) - c->bw;
    203 +	                }
    204 +	}
    205  }
    206  
    207  void