sites

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

dwm-gridmode-20170909-ceac8c9.diff (2573B)


      1 From b04bb473cf9818277d33a591f7fe2dfae96afaaf Mon Sep 17 00:00:00 2001
      2 From: Joshua Haase <hahj87@gmail.com>
      3 Date: Mon, 15 Aug 2016 17:06:18 -0500
      4 Subject: [PATCH] Apply modified gridmode patch.
      5 
      6 ---
      7  config.def.h |  3 +++
      8  layouts.c    | 27 +++++++++++++++++++++++++++
      9  2 files changed, 30 insertions(+)
     10  create mode 100644 layouts.c
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index a9ac303..30b7c4a 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -36,11 +36,13 @@ static const float mfact     = 0.55; /* factor of master area size [0.05..0.95]
     17  static const int nmaster     = 1;    /* number of clients in master area */
     18  static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
     19  
     20 +#include "layouts.c"
     21  static const Layout layouts[] = {
     22  	/* symbol     arrange function */
     23  	{ "[]=",      tile },    /* first entry is default */
     24  	{ "><>",      NULL },    /* no layout function means floating behavior */
     25  	{ "[M]",      monocle },
     26 +	{ "HHH",      grid },
     27  };
     28  
     29  /* key definitions */
     30 @@ -76,6 +78,7 @@ static Key keys[] = {
     31  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     32  	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
     33  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
     34 +	{ MODKEY,                       XK_g,      setlayout,      {.v = &layouts[3]} },
     35  	{ MODKEY,                       XK_space,  setlayout,      {0} },
     36  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
     37  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
     38 diff --git a/layouts.c b/layouts.c
     39 new file mode 100644
     40 index 0000000..d26acf3
     41 --- /dev/null
     42 +++ b/layouts.c
     43 @@ -0,0 +1,27 @@
     44 +void
     45 +grid(Monitor *m) {
     46 +	unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
     47 +	Client *c;
     48 +
     49 +	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next))
     50 +		n++;
     51 +
     52 +	/* grid dimensions */
     53 +	for(rows = 0; rows <= n/2; rows++)
     54 +		if(rows*rows >= n)
     55 +			break;
     56 +	cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
     57 +
     58 +	/* window geoms (cell height/width) */
     59 +	ch = m->wh / (rows ? rows : 1);
     60 +	cw = m->ww / (cols ? cols : 1);
     61 +	for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
     62 +		cx = m->wx + (i / rows) * cw;
     63 +		cy = m->wy + (i % rows) * ch;
     64 +		/* adjust height/width of last row/column's windows */
     65 +		ah = ((i + 1) % rows == 0) ? m->wh - ch * rows : 0;
     66 +		aw = (i >= rows * (cols - 1)) ? m->ww - cw * cols : 0;
     67 +		resize(c, cx, cy, cw - 2 * c->bw + aw, ch - 2 * c->bw + ah, False);
     68 +		i++;
     69 +	}
     70 +}
     71 -- 
     72 2.14.1
     73