sites

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

dwm-tatami-6.2.diff (4391B)


      1 diff -Naur dwm/config.def.h dwm-tatami/config.def.h
      2 --- dwm/config.def.h	2020-09-24 02:14:27.545355268 -0500
      3 +++ dwm-tatami/config.def.h	2020-09-24 02:46:12.041952267 -0500
      4 @@ -34,13 +34,15 @@
      5  /* layout(s) */
      6  static const float mfact     = 0.55; /* factor of master area size [0.05..0.95] */
      7  static const int nmaster     = 1;    /* number of clients in master area */
      8 -static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
      9 +static const int resizehints = 0;    /* 1 means respect size hints in tiled resizals */
     10  
     11 +#include "tatami.c"
     12  static const Layout layouts[] = {
     13  	/* symbol     arrange function */
     14  	{ "[]=",      tile },    /* first entry is default */
     15  	{ "><>",      NULL },    /* no layout function means floating behavior */
     16  	{ "[M]",      monocle },
     17 +	{ "|+|",      tatami },
     18  };
     19  
     20  /* key definitions */
     21 @@ -76,6 +78,7 @@
     22  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     23  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     24  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     25 +	{ MODKEY,                       XK_y,      setlayout,      {.v = &layouts[3]} },
     26  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     27  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     28  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     29 diff -Naur dwm/tatami.c dwm-tatami/tatami.c
     30 --- dwm/tatami.c	1969-12-31 18:00:00.000000000 -0600
     31 +++ dwm-tatami/tatami.c	2020-09-24 02:17:14.335349175 -0500
     32 @@ -0,0 +1,157 @@
     33 +void 
     34 +tatami(Monitor *m) {
     35 +	unsigned int i, n, nx, ny, nw, nh,
     36 +				 mats, tc,
     37 +				 tnx, tny, tnw, tnh;
     38 +	Client *c;
     39 +
     40 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), ++n);
     41 +	if(n == 0)
     42 +		return;
     43 +	
     44 +	nx = m->wx;
     45 +	ny = 0;
     46 +	nw = m->ww;
     47 +	nh = m->wh;
     48 +	
     49 +	c = nexttiled(m->clients);
     50 +	
     51 +	if(n != 1)  nw = m->ww * m->mfact;
     52 +				ny = m->wy;
     53 +				
     54 +	resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False);
     55 +	
     56 +	c = nexttiled(c->next);
     57 +	
     58 +	nx += nw;
     59 +	nw = m->ww - nw;
     60 +	
     61 +	if(n>1)
     62 +	{
     63 +	
     64 +	tc = n-1;
     65 +	mats = tc/5;
     66 +	
     67 +	nh/=(mats + (tc % 5 > 0));
     68 +	
     69 +	for(i = 0; c && (i < (tc % 5)); c = nexttiled(c->next))
     70 +	{
     71 +		tnw=nw;
     72 +		tnx=nx;
     73 +		tnh=nh;
     74 +		tny=ny;
     75 +		switch(tc - (mats*5))
     76 +				{
     77 +					case 1://fill
     78 +						break;
     79 +					case 2://up and down
     80 +						if((i % 5) == 0) //up
     81 +						tnh/=2;
     82 +						else if((i % 5) == 1) //down
     83 +						{
     84 +							tnh/=2;
     85 +							tny += nh/2;
     86 +						}
     87 +						break;
     88 +					case 3://bottom, up-left and up-right
     89 +						if((i % 5) == 0) //up-left
     90 +						{
     91 +						tnw = nw/2;
     92 +						tnh = (2*nh)/3;
     93 +						}
     94 +						else if((i % 5) == 1)//up-right
     95 +						{
     96 +							tnx += nw/2;
     97 +							tnw = nw/2;
     98 +							tnh = (2*nh)/3;
     99 +						}
    100 +						else if((i % 5) == 2)//bottom
    101 +						{
    102 +							tnh = nh/3;
    103 +							tny += (2*nh)/3;	
    104 +						}
    105 +						break;
    106 +					case 4://bottom, left, right and top
    107 +						if((i % 5) == 0) //top
    108 +						{
    109 +							tnh = (nh)/4;
    110 +						}
    111 +						else if((i % 5) == 1)//left
    112 +						{
    113 +							tnw = nw/2;
    114 +							tny += nh/4;
    115 +							tnh = (nh)/2;
    116 +						}
    117 +						else if((i % 5) == 2)//right
    118 +						{
    119 +							tnx += nw/2;
    120 +							tnw = nw/2;
    121 +							tny += nh/4;
    122 +							tnh = (nh)/2;
    123 +						}
    124 +						else if((i % 5) == 3)//bottom
    125 +						{
    126 +							tny += (3*nh)/4;
    127 +							tnh = (nh)/4;
    128 +						}
    129 +						break;
    130 +				}
    131 +		++i;
    132 +		resize(c, tnx, tny, tnw - 2 * c->bw, tnh - 2 * c->bw, False);
    133 +	}
    134 +	
    135 +	++mats;
    136 +	
    137 +	for(i = 0; c && (mats>0); c = nexttiled(c->next)) {
    138 +
    139 +			if((i%5)==0)
    140 +			{
    141 +			--mats;
    142 +			if(((tc % 5) > 0)||(i>=5))
    143 +			ny+=nh;
    144 +			}
    145 +			
    146 +			tnw=nw;
    147 +			tnx=nx;
    148 +			tnh=nh;
    149 +			tny=ny;
    150 +			
    151 +
    152 +			switch(i % 5)
    153 +			{
    154 +				case 0: //top-left-vert
    155 +					tnw = (nw)/3;
    156 +					tnh = (nh*2)/3;
    157 +					break;
    158 +				case 1: //top-right-hor
    159 +					tnx += (nw)/3;
    160 +					tnw = (nw*2)/3;
    161 +					tnh = (nh)/3;
    162 +					break;
    163 +				case 2: //center
    164 +					tnx += (nw)/3;
    165 +					tnw = (nw)/3;
    166 +					tny += (nh)/3;
    167 +					tnh = (nh)/3;
    168 +					break;
    169 +				case 3: //bottom-right-vert
    170 +					tnx += (nw*2)/3;
    171 +					tnw = (nw)/3;
    172 +					tny += (nh)/3;
    173 +					tnh = (nh*2)/3;
    174 +					break;
    175 +				case 4: //(oldest) bottom-left-hor
    176 +					tnw = (2*nw)/3;
    177 +					tny += (2*nh)/3;
    178 +					tnh = (nh)/3;
    179 +					break;
    180 +				default:
    181 +					break;
    182 +			}
    183 +			
    184 +			++i;
    185 +			//i%=5;
    186 +		resize(c, tnx, tny, tnw - 2 * c->bw, tnh - 2 * c->bw, False);
    187 +		}
    188 +	}
    189 +}