suckless-patches / dwm-5.9-bstack.diff

# HG changeset patch
# Parent 00e19065124a215008a9561d3ddab69b156ece8c
# Date 1294784085 -3600
# User Julien Jehannet <julien@smaf.org>

diff --git a/bstack.c b/bstack.c
new file mode 100644
--- /dev/null
+++ b/bstack.c
@@ -0,0 +1,29 @@
+static void
+bstack(Monitor *m) {
+	int x, y, h, w, mh;
+	unsigned int i, n;
+	Client *c;
+
+	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+	if(n == 0)
+		return;
+	/* master */
+	c = nexttiled(m->clients);
+	mh = m->mfact * m->wh;
+	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
+	if(--n == 0)
+		return;
+	/* tile stack */
+	x = m->wx;
+	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
+	w = m->ww / n;
+	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
+	if(w < bh)
+		w = m->ww;
+	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+		resize(c, x, y, /* remainder */ ((i + 1 == n)
+		       ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
+		if(w != m->ww)
+			x = c->x + WIDTH(c);
+	}
+}
diff --git a/bstackhoriz.c b/bstackhoriz.c
new file mode 100644
--- /dev/null
+++ b/bstackhoriz.c
@@ -0,0 +1,30 @@
+static void
+bstackhoriz(Monitor *m) {
+	int x, y, h, w, mh;
+	unsigned int i, n;
+	Client *c;
+
+	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+	if(n == 0)
+		return;
+	/* master */
+	c = nexttiled(m->clients);
+	mh = m->mfact * m->wh;
+	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
+	if(--n == 0)
+		return;
+	/* tile stack */
+	x = m->wx;
+	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
+	w = m->ww;
+	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
+	h /= n;
+	if(h < bh)
+		h = m->wh;
+	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
+		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
+		       ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
+		if(h != m->wh)
+			y = c->y + HEIGHT(c);
+	}
+}
diff --git a/config.def.h b/config.def.h
--- a/config.def.h
+++ b/config.def.h
@@ -29,15 +29,19 @@ static const Rule rules[] = {
 /* layout(s) */
 static const float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
 static const int nmaster      = 1;    /* number of clients in master area */
 static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
 
+#include "bstack.c"
+#include "bstackhoriz.c"
 static const Layout layouts[] = {
 	/* symbol     arrange function */
 	{ "[]=",      tile },    /* first entry is default */
 	{ "><>",      NULL },    /* no layout function means floating behavior */
 	{ "[M]",      monocle },
+	{ "TTT",      bstack },
+	{ "===",      bstackhoriz },
 };
 
 /* key definitions */
 #define MODKEY Mod1Mask
 #define TAGKEYS(KEY,TAG) \
diff --git a/config.h b/config.h
--- a/config.h
+++ b/config.h
@@ -32,15 +32,19 @@ static const Rule rules[] = {
 /* layout(s) */
 static const float mfact      = 0.55; /* factor of master area size [0.05..0.95] */
 static const int nmaster      = 1;    /* number of clients in master area */
 static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
 
+#include "bstack.c"
+#include "bstackhoriz.c"
 static const Layout layouts[] = {
 	/* symbol     arrange function */
 	{ "τ",        tile },    /* first entry is default */
 	{ "≈",        NULL },    /* no layout function means floating behavior */
 	{ "⇔",        monocle },
+	{ "Ⅱ",        bstack },
+	{ "‗",        bstackhoriz },
 };
 
 /* key definitions */
 #define MODKEY Mod4Mask
 #define TAGKEYS(KEY,TAG) \
@@ -80,13 +84,13 @@ static Key keys[] = {
 	{ MODKEY|ControlMask,           XK_Left,                zoom,           {0} },
 	{ MODKEY|ControlMask,           XK_Right,               zoom,           {0} },
 	{ MODKEY|ControlMask,           XK_Return,              zoom,           {0} },
 	{ MODKEY,                       XK_Tab,                 view,           {0} },
 	{ MODKEY,                       XK_space,               zoom,           {0} },
-	//{ MODKEY|ShiftMask,             XK_space,               setlayout,      {0} },
-	//{ MODKEY|ControlMask,           XK_space,               setlayout,      {.v = &layouts[2]} },
 	{ MODKEY|ControlMask,           XK_space,               setlayout,      {0} },
+	{ MODKEY|ShiftMask,             XK_s,                   setlayout,      {.v = &layouts[4]} },
+	{ MODKEY,                       XK_s,                   setlayout,      {.v = &layouts[3]} },
 	{ MODKEY,                       XK_f,                   setlayout,      {.v = &layouts[2]} },
 	{ MODKEY|ControlMask,           XK_f,                   setlayout,      {.v = &layouts[1]} },
 	{ MODKEY,                       XK_d,                   setlayout,      {.v = &layouts[0]} },
 	{ MODKEY,                       XK_t,                   setlayout,      {.v = &layouts[0]} },
 	{ MODKEY|ShiftMask,             XK_f,                   togglefloating, {0} },
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.