sites

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

dwm-ru_fibonacci-6.2.diff (2377B)


      1 diff -upN a/config.def.h b/config.def.h
      2 --- a/config.def.h	2019-05-28 13:43:00.326646120 +0200
      3 +++ b/config.def.h	2019-05-28 21:17:55.213171996 +0200
      4 @@ -36,8 +36,11 @@ static const float mfact     = 0.55; /*
      5  static const int nmaster     = 1;    /* number of clients in master area */
      6  static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
      7  
      8 +#include "fibonacci.c"
      9  static const Layout layouts[] = {
     10  	/* symbol     arrange function */
     11 + 	{ "[@]",      spiral },
     12 + 	{ "[\\]",     dwindle },
     13  	{ "[]=",      tile },    /* first entry is default */
     14  	{ "><>",      NULL },    /* no layout function means floating behavior */
     15  	{ "[M]",      monocle },
     16 diff -upN a/fibonacci.c b/fibonacci.c
     17 --- a/fibonacci.c	1970-01-01 01:00:00.000000000 +0100
     18 +++ b/fibonacci.c	2019-05-28 21:07:51.119850125 +0200
     19 @@ -0,0 +1,74 @@
     20 +static void
     21 +fibonacci(Monitor *m, int s)
     22 +{
     23 +	unsigned int i, n;
     24 +	int nx, ny, nw, nh;
     25 +	Client *c;
     26 +
     27 +	for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
     28 +	if (n == 0)
     29 +		return;
     30 +	if (n == 1) {
     31 +		c = nexttiled(m->clients);
     32 +		resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
     33 +		return;
     34 +	}
     35 +
     36 +	nx = m->wx + m->gappx;
     37 +	ny = m->gappx;
     38 +	nw = m->ww - 2*m->gappx;
     39 +	nh = m->wh - 2*m->gappx;
     40 +
     41 +	for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
     42 +		if ((i % 2 && nh / 2 > 2*c->bw)
     43 +		   || (!(i % 2) && nw / 2 > 2*c->bw)) {
     44 +			if (i < n - 1) {
     45 +				if (i % 2)
     46 +					nh = (nh - m->gappx) / 2;
     47 +				else
     48 +					nw = (nw - m->gappx) / 2;
     49 +
     50 +				if ((i % 4) == 2 && !s)
     51 +					nx += nw + m->gappx;
     52 +				else if ((i % 4) == 3 && !s)
     53 +					ny += nh + m->gappx;
     54 +			}
     55 +			if ((i % 4) == 0) {
     56 +				if (s)
     57 +					ny += nh + m->gappx;
     58 +				else
     59 +					ny -= nh + m->gappx;
     60 +			}
     61 +			else if ((i % 4) == 1)
     62 +				nx += nw + m->gappx;
     63 +			else if ((i % 4) == 2)
     64 +				ny += nh + m->gappx;
     65 +			else if ((i % 4) == 3) {
     66 +				if (s)
     67 +					nx += nw + m->gappx;
     68 +				else
     69 +					nx -= nw + m->gappx;
     70 +			}
     71 +			if (i == 0)	{
     72 +				if (n != 1)
     73 +					nw = (m->ww - 2*m->gappx - m->gappx) * m->mfact;
     74 +				ny = m->wy + m->gappx;
     75 +			}
     76 +			else if (i == 1)
     77 +				nw = m->ww - nw - m->gappx - 2*m->gappx;
     78 +			i++;
     79 +		}
     80 +
     81 +		resize(c, nx, ny, nw - (2*c->bw), nh - (2*c->bw), False);
     82 +	}
     83 +}
     84 +
     85 +void
     86 +dwindle(Monitor *mon) {
     87 +	fibonacci(mon, 1);
     88 +}
     89 +
     90 +void
     91 +spiral(Monitor *mon) {
     92 +	fibonacci(mon, 0);
     93 +}