sites

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

dwm-ru_bottomstack-6.2.diff (4080B)


      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,87 @@ 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 +			if(mx + WIDTH(c) + m->gappx < m->mw)
     67 +				mx += WIDTH(c) + m->gappx;
     68 +		} else {
     69 +			w = (m->ww - tx) / (n - i) - m->gappx;
     70 +			if(m->nmaster == 0)
     71 +				resize(c, m->wx + tx, m->wy + mh, w - (2*c->bw), m->wh - mh - 2*c->bw - m->gappx, False);
     72 +			else
     73 +				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);
     74 +			if (tx + WIDTH(c) + m->gappx < m->mw)
     75 +				tx += WIDTH(c) + m->gappx;
     76 +		}
     77 +}
     78 +
     79 +void
     80 +bstackhoriz(Monitor *m)
     81 +{
     82 +	unsigned int i, n;
     83 +	int mx = 0, my = 0, mh = 0, mw = 0;
     84 +	int sx = 0, sy = 0, sh = 0, sw = 0;
     85 +	Client *c;
     86 +
     87 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     88 +	if (n == 0)
     89 +		return;
     90 +
     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 +	sx = mx = m->wx + m->gappx;
     98 +	sy = my = m->wy + m->gappx;
     99 +	sh = mh = m->wh - 2*m->gappx;
    100 +	sw = mw = m->ww - 2*m->gappx - m->gappx * (MIN(n, m->nmaster) - 1);
    101 +
    102 +	if (m->nmaster && n > m->nmaster) {
    103 +		sh = (mh - m->gappx) * (1 - m->mfact);
    104 +		mh = (mh - m->gappx) * m->mfact;
    105 +		sy = my + mh + m->gappx;
    106 +		sh = m->wh - mh - 2*m->gappx - m->gappx * (n - m->nmaster);
    107 +		sw = m->ww - 2*m->gappx;
    108 +	}
    109 +
    110 +	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
    111 +		if (i < m->nmaster) {
    112 +			resize(c, mx, my, mw / MIN(n, m->nmaster) - (2*c->bw), mh - (2*c->bw), 0);
    113 +			if(mx + WIDTH(c) + m->gappx < m->mw)
    114 +				mx += WIDTH(c) + m->gappx;
    115 +		} else {
    116 +			resize(c, sx, sy, sw - (2*c->bw), sh / (n - MIN(n, m->nmaster)) - (2*c->bw), 0);
    117 +			if(sy + HEIGHT(c) + m->gappx < m->mh)
    118 +				sy += HEIGHT(c) + m->gappx;
    119 +		}
    120 +	}
    121 +}