This commit is contained in:
Cadey Ratio 2020-06-03 19:29:37 -04:00
parent 299c70874c
commit 8ea55d3974
2 changed files with 69 additions and 1 deletions

View File

@ -63,6 +63,8 @@ static const Layout layouts[] = {
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "TTT", bstack },
{ "===", bstackhoriz },
};
/* key definitions */
@ -100,10 +102,12 @@ static Key keys[] = {
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY|ShiftMask, XK_f, spawn, {.v = frontcmd } },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY|ShiftMask, XK_f, spawn, {.v = frontcmd } },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_e, spawn, {.v = emacscmd } },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },

64
dwm.c
View File

@ -282,6 +282,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void xinitvisual();
static void zoom(const Arg *arg);
static void bstack(Monitor *m);
static void bstackhoriz(Monitor *m);
/* variables */
static Systray *systray = NULL;
@ -2770,3 +2772,65 @@ main(int argc, char *argv[])
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}
static void
bstack(Monitor *m) {
int w, h, mh, mx, tx, ty, tw;
unsigned int i, n;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (n > m->nmaster) {
mh = m->nmaster ? m->mfact * m->wh : 0;
tw = m->ww / (n - m->nmaster);
ty = m->wy + mh;
} else {
mh = m->wh;
tw = m->ww;
ty = m->wy;
}
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
if (i < m->nmaster) {
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
mx += WIDTH(c);
} else {
h = m->wh - mh;
resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0);
if (tw != m->ww)
tx += WIDTH(c);
}
}
}
static void
bstackhoriz(Monitor *m) {
int w, mh, mx, tx, ty, th;
unsigned int i, n;
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if (n == 0)
return;
if (n > m->nmaster) {
mh = m->nmaster ? m->mfact * m->wh : 0;
th = (m->wh - mh) / (n - m->nmaster);
ty = m->wy + mh;
} else {
th = mh = m->wh;
ty = m->wy;
}
for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
if (i < m->nmaster) {
w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0);
mx += WIDTH(c);
} else {
resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0);
if (th != m->wh)
ty += HEIGHT(c);
}
}
}