sites

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

dwm-ru_bottomstack-6.2.diff (3695B)


      1 diff -up a/config.def.h b/config.def.h
      2 --- a/config.def.h	2019-07-24 08:59:14.429282151 +0200
      3 +++ b/config.def.h	2019-07-24 09:01:08.983271468 +0200
      4 @@ -42,6 +42,8 @@ static const Layout layouts[] = {
      5  	{ "[]=",      tile },    /* first entry is default */
      6  	{ "><>",      NULL },    /* no layout function means floating behavior */
      7  	{ "[M]",      monocle },
      8 +	{ "TTT",      bstack },
      9 +	{ "===",      bstackhoriz },
     10  };
     11  
     12  /* key definitions */
     13 @@ -77,6 +79,8 @@ static Key keys[] = {
     14  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     15  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     16  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     17 +   { MODKEY,                       XK_u,      setlayout,      {.v = &layouts[3]} },
     18 +   { MODKEY|ShiftMask,             XK_u,      setlayout,      {.v = &layouts[4]} },
     19  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     20  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     21  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     22 diff -up a/dwm.c b/dwm.c
     23 --- a/dwm.c	2019-07-24 08:59:14.432615503 +0200
     24 +++ b/dwm.c	2019-07-24 09:04:22.097731306 +0200
     25 @@ -211,6 +211,8 @@ static void spawn(const Arg *arg);
     26  static void tag(const Arg *arg);
     27  static void tagmon(const Arg *arg);
     28  static void tile(Monitor *);
     29 +static void bstack(Monitor *);
     30 +static void bstackhoriz(Monitor *);
     31  static void togglebar(const Arg *arg);
     32  static void togglefloating(const Arg *arg);
     33  static void toggletag(const Arg *arg);
     34 @@ -2176,3 +2178,74 @@ main(int argc, char *argv[])
     35  	XCloseDisplay(dpy);
     36  	return EXIT_SUCCESS;
     37  }
     38 +
     39 +void
     40 +bstack(Monitor *m)
     41 +{
     42 +	unsigned int i, n, w, mh, mx, tx, ns;
     43 +	Client *c;
     44 +
     45 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     46 +	if (n == 0)
     47 +		return;
     48 +	if(n == 1){
     49 +		c = nexttiled(m->clients);
     50 +		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
     51 +		return;
     52 +	}
     53 +
     54 +	if (n > m->nmaster){
     55 +		mh = m->nmaster ? m->wh * m->mfact : m->gappx;
     56 +		ns = 2;
     57 +	}
     58 +	else{
     59 +		mh = m->wh;
     60 +		ns = 1;
     61 +	}
     62 +	for (i = 0, mx = tx = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     63 +		if (i < m->nmaster) {
     64 +			w = (m->ww - mx) / (MIN(n, m->nmaster) - i) - m->gappx;
     65 +			resize(c, m->wx + mx, m->wy + m->gappx, w - 2*c->bw, mh - 2*c->bw - m->gappx*(5-ns)/2, 0);
     66 +			mx += WIDTH(c) + m->gappx;
     67 +		} else {
     68 +			w = (m->ww - tx) / (n - i) - m->gappx;
     69 +			if(m->nmaster == 0)
     70 +				resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*c->bw - m->gappx, False);
     71 +			else
     72 +				resize(c, m->wx + tx, m->wy + mh + m->gappx/ns, w - (2*c->bw), m->wh - mh - 2*c->bw - m->gappx*(5-ns)/2, False);
     73 +			tx += WIDTH(c) + m->gappx;
     74 +		}
     75 +}
     76 +
     77 +void
     78 +bstackhoriz(Monitor *m)
     79 +{
     80 +	unsigned int i, n, h, mw, mh, my, ty;
     81 +	Client *c;
     82 +
     83 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     84 +	if (n == 0)
     85 +		return;
     86 +	if(n == 1){
     87 +		c = nexttiled(m->clients);
     88 +		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
     89 +		return;
     90 +	}
     91 +
     92 +	if (n > m->nmaster)
     93 +		mh = m->nmaster ? m->wh * m->mfact : m->gappx;
     94 +	else
     95 +		mh = m->wh;
     96 +	mw = m->ww;
     97 +
     98 +	for (i = ty = 0, my = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
     99 +		if (i < m->nmaster) {
    100 +			h = (mh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
    101 +			resize(c, m->wx + m->gappx, m->wy + my, mw - 2*(c->bw + m->gappx), h - (2*c->bw), 0);
    102 +			my += HEIGHT(c) + m->gappx;
    103 +		} else {
    104 +			h = (m->wh - mh - ty) / (n - i) - m->gappx;
    105 +			resize(c, m->wx + m->gappx, m->wy + mh + ty, mw - 2*(c->bw + m->gappx), h - (2*c->bw), 0);
    106 +			ty += HEIGHT(c) + m->gappx;
    107 +		}
    108 +}