sites

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

dwm-ru_fibonacci-6.2.diff (2420B)


      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,73 @@
     20 +void fibonacci(Monitor *mon, int s) {
     21 +	unsigned int i, n, nx, ny, nw, nh;
     22 +	Client *c;
     23 +
     24 +	for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++);
     25 +	if(n == 0)
     26 +		return;
     27 +	if(n == 1){
     28 +		c = nexttiled(mon->clients);
     29 +		resize(c, mon->wx, mon->wy, mon->ww - 2 * c->bw, mon->wh - 2 * c->bw, 0);
     30 +		return;
     31 +	}
     32 +	
     33 +	nx = mon->wx;
     34 +	ny = mon->gappx;
     35 +	nw = mon->ww;
     36 +	nh = mon->wh;
     37 +	
     38 +	for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) {
     39 +		if((i % 2 && nh / 2 > 2 * c->bw)
     40 +		   || (!(i % 2) && nw / 2 > 2 * c->bw)) {
     41 +			if(i < n - 1) {
     42 +				if(i % 2)
     43 +					nh /= 2;
     44 +				else
     45 +					nw /= 2;
     46 +				if((i % 4) == 2 && !s)
     47 +					nx += nw;
     48 +				else if((i % 4) == 3 && !s)
     49 +					ny += nh;
     50 +			}
     51 +			if((i % 4) == 0) {
     52 +				if(s)
     53 +					ny += nh;
     54 +				else
     55 +					ny -= nh;
     56 +			}
     57 +			else if((i % 4) == 1)
     58 +				nx += nw;
     59 +			else if((i % 4) == 2)
     60 +				ny += nh;
     61 +			else if((i % 4) == 3) {
     62 +				if(s)
     63 +					nx += nw;
     64 +				else
     65 +					nx -= nw;
     66 +			}
     67 +			if(i == 0)
     68 +			{
     69 +				if(n != 1)
     70 +					nw = mon->ww * mon->mfact;
     71 +				ny = mon->wy + mon->gappx;
     72 +			}
     73 +			else if(i == 1)
     74 +				nw = mon->ww - nw - mon->gappx;
     75 +			i++;
     76 +		}
     77 +		if((s == 0 && i <= 4 && (i!=2 || n==2)) || (s==1 && (i%2==1 || i==n)))
     78 +			resize(c, nx + mon->gappx, ny, nw - 2 * (c->bw) - mon->gappx, nh - 2 * (c->bw) - 2*mon->gappx, False);
     79 +		else
     80 +			resize(c, nx + mon->gappx, ny, nw - 2 * (c->bw) - mon->gappx, nh - 2 * (c->bw) - mon->gappx, False);
     81 +	}
     82 +}
     83 +
     84 +void
     85 +dwindle(Monitor *mon) {
     86 +	fibonacci(mon, 1);
     87 +}
     88 +
     89 +void
     90 +spiral(Monitor *mon) {
     91 +	fibonacci(mon, 0);
     92 +}