Skip to content

Commit

Permalink
Adds tripple col layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab2870 committed May 20, 2019
1 parent e359481 commit 8a9ab33
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
static const int attachbelow = 1; /* 1 means attach after the currently active window */

#include "tcl.c"

static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "|||", tcl },
};

/* key definitions */
Expand Down Expand Up @@ -91,6 +94,7 @@ static Key keys[] = {
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
Expand Down
74 changes: 74 additions & 0 deletions tcl.c
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 8a9ab33

Please sign in to comment.