Added new layout with three columns, wide master in the middle.
authorAaron Taylor <ataylor@subgeniuskitty.com>
Fri, 3 Feb 2023 23:36:42 +0000 (15:36 -0800)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Fri, 3 Feb 2023 23:36:42 +0000 (15:36 -0800)
https://dwm.suckless.org/patches/three-column/

README
config.def.h
config.h
layoutmenu.sh
tcl.c [new file with mode: 0644]

diff --git a/README b/README
index fcb2ba4..fc3c58b 100644 (file)
--- a/README
+++ b/README
@@ -2,6 +2,9 @@ This git repository contains my personal branch of dwm-6.4.
 
 The changes made to stock dwm add the following abilities.
 
 
 The changes made to stock dwm add the following abilities.
 
+  - Added new layout with three columns, master in the middle.
+    <https://dwm.suckless.org/patches/three-column/>
+
   - Draw per-client indicators in the tag section of the status bar.
     <https://dwm.suckless.org/patches/clientindicators/>
 
   - Draw per-client indicators in the tag section of the status bar.
     <https://dwm.suckless.org/patches/clientindicators/>
 
index 7680b82..12bbb42 100644 (file)
@@ -39,11 +39,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 */
 
 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 */
        { "[]=",      tile },    /* first entry is default */
        { "><>",      NULL },    /* no layout function means floating behavior */
        { "[M]",      monocle },
 static const Layout layouts[] = {
        /* symbol     arrange function */
        { "[]=",      tile },    /* first entry is default */
        { "><>",      NULL },    /* no layout function means floating behavior */
        { "[M]",      monocle },
+       { "|||",      tcl },
 };
 
 /* key definitions */
 };
 
 /* key definitions */
index 75b776e..9590e25 100644 (file)
--- a/config.h
+++ b/config.h
@@ -42,11 +42,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 */
 
 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 */
        { "[]=",      tile },    /* first entry is default */
        { "><>",      NULL },    /* no layout function means floating behavior */
        { "[M]",      monocle },
 static const Layout layouts[] = {
        /* symbol     arrange function */
        { "[]=",      tile },    /* first entry is default */
        { "><>",      NULL },    /* no layout function means floating behavior */
        { "[M]",      monocle },
+       { "|||",      tcl },
 };
 
 /* key definitions */
 };
 
 /* key definitions */
index 1bf95f2..3ca2f0f 100644 (file)
@@ -4,4 +4,5 @@ cat <<EOF | xmenu
 []= Tiled Layout       0
 ><> Floating Layout    1
 [M] Monocle Layout     2
 []= Tiled Layout       0
 ><> Floating Layout    1
 [M] Monocle Layout     2
+||| 3-Column Layout    3
 EOF
 EOF
diff --git a/tcl.c b/tcl.c
new file mode 100644 (file)
index 0000000..4c94914
--- /dev/null
+++ 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);
+       }
+}