Add gaplessgrid patch
This commit is contained in:
parent
a039af0a87
commit
976638aa52
|
@ -67,8 +67,9 @@ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen win
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "###", gaplessgrid },
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "[]=", tile },
|
||||||
|
{ "><>", NULL },
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
config.h
2
config.h
|
@ -63,6 +63,8 @@ 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 resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
|
||||||
|
#include "layouts.c"
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
{ "[]=", tile }, /* first entry is default */
|
{ "[]=", tile }, /* first entry is default */
|
||||||
|
|
2
dwm.c
2
dwm.c
|
@ -182,7 +182,6 @@ static void killclient(const Arg *arg);
|
||||||
static void manage(Window w, XWindowAttributes *wa);
|
static void manage(Window w, XWindowAttributes *wa);
|
||||||
static void mappingnotify(XEvent *e);
|
static void mappingnotify(XEvent *e);
|
||||||
static void maprequest(XEvent *e);
|
static void maprequest(XEvent *e);
|
||||||
static void monocle(Monitor *m);
|
|
||||||
static void motionnotify(XEvent *e);
|
static void motionnotify(XEvent *e);
|
||||||
static void movemouse(const Arg *arg);
|
static void movemouse(const Arg *arg);
|
||||||
static Client *nexttiled(Client *c);
|
static Client *nexttiled(Client *c);
|
||||||
|
@ -210,7 +209,6 @@ static void showhide(Client *c);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
static void tagmon(const Arg *arg);
|
static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
|
||||||
static void togglebar(const Arg *arg);
|
static void togglebar(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglefullscr(const Arg *arg);
|
static void togglefullscr(const Arg *arg);
|
||||||
|
|
37
layouts.c
37
layouts.c
|
@ -40,3 +40,40 @@ monocle(Monitor *m)
|
||||||
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
|
||||||
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add gaps
|
||||||
|
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