commit 009ec08e1c6fe5b28ccec6a0a72f23799205b8d8
parent d0ee3009432cc9184c5c943fe64014d45f21033f
Author: Robert Russell <robert@rr3.xyz>
Date: Sun, 22 Sep 2024 14:25:31 -0700
Add column layout
Diffstat:
| M | config.h | | | 13 | ++++++++----- |
| A | tcl.c | | | 74 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/config.h b/config.h
@@ -11,7 +11,7 @@ static const char col_gray1[] = "#222222";
static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee";
-static const char col_green[] = "#126912";
+static const char col_green[] = "#126912";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
@@ -36,11 +36,13 @@ 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 lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+#include "tcl.c"
static const Layout layouts[] = {
/* symbol arrange function */
- { "T", tile }, /* first entry is default */
- { "F", NULL }, /* no layout function means floating behavior */
- { "M", monocle },
+ { "T", tile }, /* first entry is default */
+ { "F", NULL }, /* no layout function means floating behavior */
+ { "C", tcl },
+ //{ "M", monocle },
};
/* key definitions */
@@ -72,12 +74,13 @@ static const Key keys[] = {
{ MODKEY, XK_Prior, incnmaster, {.i = -1 } },
{ MODKEY|ShiftMask, XK_Left, setmfact, {.f = -0.05} },
{ MODKEY|ShiftMask, XK_Right, setmfact, {.f = +0.05} },
+ { MODKEY|ShiftMask, XK_c, setmfact, {.f = +1.33} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
- { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XK_c, setlayout, {.v = &layouts[2]} },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff --git a/tcl.c b/tcl.c
@@ -0,0 +1,74 @@
+void
+tcl(Monitor * m)
+{
+ int x, y, h, w, mw, sw, bdw;
+ unsigned int i, n;
+ Client * c;
+
+ for (n = 0, c = nexttiled(m->clients); c;
+ c = nexttiled(c->next), n++);
+
+ if (n == 0)
+ return;
+
+ c = nexttiled(m->clients);
+
+ mw = m->mfact * m->ww;
+ sw = (m->ww - mw) / 2;
+ bdw = (2 * c->bw);
+ resize(c,
+ n < 3 ? m->wx : m->wx + sw,
+ m->wy,
+ n == 1 ? m->ww - bdw : mw - bdw,
+ m->wh - bdw,
+ False);
+
+ if (--n == 0)
+ return;
+
+ w = (m->ww - mw) / ((n > 1) + 1);
+ c = nexttiled(c->next);
+
+ if (n > 1)
+ {
+ x = m->wx + ((n > 1) ? mw + sw : mw);
+ y = m->wy;
+ h = m->wh / (n / 2);
+
+ if (h < bh)
+ h = m->wh;
+
+ for (i = 0; c && i < n / 2; c = nexttiled(c->next), i++)
+ {
+ resize(c,
+ x,
+ y,
+ w - bdw,
+ (i + 1 == n / 2) ? m->wy + m->wh - y - bdw : h - bdw,
+ False);
+
+ if (h != m->wh)
+ y = c->y + HEIGHT(c);
+ }
+ }
+
+ x = (n + 1 / 2) == 1 ? mw : m->wx;
+ y = m->wy;
+ h = m->wh / ((n + 1) / 2);
+
+ if (h < bh)
+ h = m->wh;
+
+ for (i = 0; c; c = nexttiled(c->next), i++)
+ {
+ resize(c,
+ x,
+ y,
+ (i + 1 == (n + 1) / 2) ? w - bdw : w - bdw,
+ (i + 1 == (n + 1) / 2) ? m->wy + m->wh - y - bdw : h - bdw,
+ False);
+
+ if (h != m->wh)
+ y = c->y + HEIGHT(c);
+ }
+}