Add gaplessgrid patch
This commit is contained in:
parent
4d9d5e5fb4
commit
f2e1738e6a
2
config.h
2
config.h
@ -46,6 +46,7 @@ static const Layout layouts[] = {
|
||||
{ "[M]", monocle },
|
||||
{ "TTT", bstack },
|
||||
{ "===", bstackhoriz },
|
||||
{ "-|_", gaplessgrid },
|
||||
};
|
||||
|
||||
/* key definitions */
|
||||
@ -112,6 +113,7 @@ static const Key keys[] = {
|
||||
{ MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY|ShiftMask, XK_o, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY|ShiftMask, XK_g, setlayout, {.v = &layouts[5]} },
|
||||
{ MODKEY|ShiftMask, XK_d, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||
|
37
dwm.c
37
dwm.c
@ -236,6 +236,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
static void bstack(Monitor *m);
|
||||
static void bstackhoriz(Monitor *m);
|
||||
static void gaplessgrid(Monitor *m);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@ -2228,3 +2229,39 @@ bstackhoriz(Monitor *m) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gaplessgrid(Monitor *m) {
|
||||
unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
|
||||
Client *c;
|
||||
|
||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
|
||||
if(n == 0)
|
||||
return;
|
||||
|
||||
/* grid dimensions */
|
||||
for(cols = 0; cols <= n/2; cols++)
|
||||
if(cols*cols >= n)
|
||||
break;
|
||||
if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||
cols = 2;
|
||||
rows = n/cols;
|
||||
|
||||
/* window geometries */
|
||||
cw = cols ? m->ww / cols : m->ww;
|
||||
cn = 0; /* current column number */
|
||||
rn = 0; /* current row number */
|
||||
for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
|
||||
if(i/rows + 1 > cols - n%cols)
|
||||
rows = n/cols + 1;
|
||||
ch = rows ? m->wh / rows : m->wh;
|
||||
cx = m->wx + cn*cw;
|
||||
cy = m->wy + rn*ch;
|
||||
resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
|
||||
rn++;
|
||||
if(rn >= rows) {
|
||||
rn = 0;
|
||||
cn++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user