Add grid patch
This commit is contained in:
		| @ -65,11 +65,13 @@ static const int nmaster     = 1;    /* number of clients in master area */ | ||||
| static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */ | ||||
| static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ | ||||
|  | ||||
| #include "layouts.c" | ||||
| static const Layout layouts[] = { | ||||
| 	/* symbol     arrange function */ | ||||
| 	{ "[]=",      tile },    /* first entry is default */ | ||||
| 	{ "><>",      NULL },    /* no layout function means floating behavior */ | ||||
| 	{ "[M]",      monocle }, | ||||
| 	{ "HHH",      grid }, | ||||
| }; | ||||
|  | ||||
| /* key definitions */ | ||||
| @ -125,6 +127,7 @@ static Key keys[] = { | ||||
| 	{ SUPERKEY,                     XK_t,                     setlayout,      {.v = &layouts[0]} }, | ||||
| 	{ SUPERKEY,                     XK_f,                     setlayout,      {.v = &layouts[1]} }, | ||||
| 	{ SUPERKEY,                     XK_m,                     setlayout,      {.v = &layouts[2]} }, | ||||
| 	{ SUPERKEY,                     XK_g,			  setlayout,      {.v = &layouts[3]} }, | ||||
| /*	{ SUPERKEY,                     XK_space,                 setlayout,      {0} }, */ | ||||
| 	{ SUPERKEY|ShiftMask,           XK_space,                 togglefloating, {0} }, | ||||
| 	{ SUPERKEY,                     XK_0,                     view,           {.ui = ~0 } }, | ||||
|  | ||||
							
								
								
									
										27
									
								
								layouts.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								layouts.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| void | ||||
| grid(Monitor *m) { | ||||
| 	unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows; | ||||
| 	Client *c; | ||||
|  | ||||
| 	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) | ||||
| 		n++; | ||||
|  | ||||
| 	/* grid dimensions */ | ||||
| 	for(rows = 0; rows <= n/2; rows++) | ||||
| 		if(rows*rows >= n) | ||||
| 			break; | ||||
| 	cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; | ||||
|  | ||||
| 	/* window geoms (cell height/width) */ | ||||
| 	ch = m->wh / (rows ? rows : 1); | ||||
| 	cw = m->ww / (cols ? cols : 1); | ||||
| 	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) { | ||||
| 		cx = m->wx + (i / rows) * cw; | ||||
| 		cy = m->wy + (i % rows) * ch; | ||||
| 		/* adjust height/width of last row/column's windows */ | ||||
| 		ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0; | ||||
| 		aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0; | ||||
| 		resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False); | ||||
| 		i++; | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user