[wiki] [sites] [dwm][patch] add stairs patch || Ehsan Ghorbannezhad

From: <git_AT_suckless.org>
Date: Sat, 30 Apr 2022 20:16:00 +0200

commit 93116d30ad584292350d62732e8da24eaf006317
Author: Ehsan Ghorbannezhad <ehsan_AT_disroot.org>
Date: Sat Apr 30 22:36:34 2022 +0430

    [dwm][patch] add stairs patch
    
    this patch adds a new layout called stairs.

diff --git a/dwm.suckless.org/patches/stairs/dwm-stairs-20220430-8b48e30.diff b/dwm.suckless.org/patches/stairs/dwm-stairs-20220430-8b48e30.diff
new file mode 100644
index 00000000..ce844b0f
--- /dev/null
+++ b/dwm.suckless.org/patches/stairs/dwm-stairs-20220430-8b48e30.diff
_AT_@ -0,0 +1,98 @@
+From a189dd70bd7c0789a11f304ceb75fd2d66fa405d Mon Sep 17 00:00:00 2001
+From: Ehsan Ghorbannezhad <ehsan_AT_disroot.org>
+Date: Sat, 30 Apr 2022 01:15:20 +0430
+Subject: [PATCH] add a new layout called stairs
+
+---
+ config.def.h | 5 +++++
+ dwm.c | 38 ++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 43 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..7774f1e 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -5,6 +5,9 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
++static const unsigned int stairpx = 20; /* depth of the stairs layout */
++static const int stairdirection = 1; /* 0: left-aligned, 1: right-aligned */
++static const int stairsamesize = 1; /* 1 means shrink all the staired windows to the same size */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+_AT_@ -42,6 +45,7 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "[S]", stairs },
+ };
+
+ /* key definitions */
+_AT_@ -77,6 +81,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, XK_s, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+diff --git a/dwm.c b/dwm.c
+index 5646a5c..fcdbb06 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -207,6 +207,7 @@ static void seturgent(Client *c, int urg);
+ static void showhide(Client *c);
+ static void sigchld(int unused);
+ static void spawn(const Arg *arg);
++static void stairs(Monitor *m);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+_AT_@ -1659,6 +1660,43 @@ spawn(const Arg *arg)
+ }
+ }
+
++void
++stairs(Monitor *m)
++{
++ unsigned int i, n, h, mw, my;
++ unsigned int ox, oy, ow, oh; /* stair offset values */
++ Client *c;
++
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ if (n == 0)
++ return;
++
++ if (n > m->nmaster)
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ else
++ mw = m->ww;
++
++ for (i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
++ if (i < m->nmaster) {
++ h = (m->wh - my) / (MIN(n, m->nmaster) - i);
++ resize(c, m->wx, m->wy + my, mw - (2 * c->bw), h - (2 * c->bw), 0);
++ if (my + HEIGHT(c) < m->wh)
++ my += HEIGHT(c);
++ } else {
++ oy = i - m->nmaster;
++ ox = stairdirection ? n - i - 1 : (stairsamesize ? i - m->nmaster : 0);
++ ow = stairsamesize ? n - m->nmaster - 1 : n - i - 1;
++ oh = stairsamesize ? ow : i - m->nmaster;
++ resize(c,
++ m->wx + mw + (ox * stairpx),
++ m->wy + (oy * stairpx),
++ m->ww - mw - (2 * c->bw) - (ow * stairpx),
++ m->wh - (2 * c->bw) - (oh * stairpx),
++ 0);
++ }
++ }
++}
++
+ void
+ tag(const Arg *arg)
+ {
+--
+2.36.0
diff --git a/dwm.suckless.org/patches/stairs/dwm-stairs-fullgaps-20220430-8b48e30.diff b/dwm.suckless.org/patches/stairs/dwm-stairs-fullgaps-20220430-8b48e30.diff
new file mode 100644
index 00000000..53e79669
--- /dev/null
+++ b/dwm.suckless.org/patches/stairs/dwm-stairs-fullgaps-20220430-8b48e30.diff
_AT_@ -0,0 +1,98 @@
+From 2004db267a9478918699961ab2f3579c2c8113fb Mon Sep 17 00:00:00 2001
+From: Ehsan Ghorbannezhad <ehsan_AT_disroot.org>
+Date: Sat, 30 Apr 2022 02:48:58 +0430
+Subject: [PATCH] add the stairs layout with fullgaps support
+
+---
+ config.def.h | 5 +++++
+ dwm.c | 38 ++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 43 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 5b0d4de..c0f24f4 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -6,6 +6,9 @@ static const unsigned int gappx = 5; /* gaps between windows */
+ static const unsigned int snap = 32; /* snap pixel */
+ static const int showbar = 1; /* 0 means no bar */
+ static const int topbar = 1; /* 0 means bottom bar */
++static const unsigned int stairpx = 20; /* depth of the stairs layout */
++static const int stairdirection = 1; /* 0: left-aligned, 1: right-aligned */
++static const int stairsamesize = 1; /* 1 means shrink all the staired windows to the same size */
+ static const char *fonts[] = { "monospace:size=10" };
+ static const char dmenufont[] = "monospace:size=10";
+ static const char col_gray1[] = "#222222";
+_AT_@ -43,6 +46,7 @@ static const Layout layouts[] = {
+ { "[]=", tile }, /* first entry is default */
+ { "><>", NULL }, /* no layout function means floating behavior */
+ { "[M]", monocle },
++ { "[S]", stairs },
+ };
+
+ /* key definitions */
+_AT_@ -78,6 +82,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, XK_s, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XK_space, setlayout, {0} },
+ { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY, XK_0, view, {.ui = ~0 } },
+diff --git a/dwm.c b/dwm.c
+index 5b7348c..2c5380f 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -209,6 +209,7 @@ static void seturgent(Client *c, int urg);
+ static void showhide(Client *c);
+ static void sigchld(int unused);
+ static void spawn(const Arg *arg);
++static void stairs(Monitor *m);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+_AT_@ -1672,6 +1673,43 @@ spawn(const Arg *arg)
+ }
+ }
+
++void
++stairs(Monitor *m)
++{
++ unsigned int i, n, h, mw, my;
++ unsigned int ox, oy, ow, oh; /* stair offset values */
++ Client *c;
++
++ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
++ if (n == 0)
++ return;
++
++ if (n > m->nmaster)
++ mw = m->nmaster ? m->ww * m->mfact : 0;
++ else
++ mw = m->ww - m->gappx;
++
++ for (i = 0, my = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
++ if (i < m->nmaster) {
++ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
++ resize(c, m->wx + m->gappx, m->wy + my, mw - (2 * c->bw) - m->gappx, h - (2 * c->bw), 0);
++ if (my + HEIGHT(c) + m->gappx < m->wh)
++ my += HEIGHT(c) + m->gappx;
++ } else {
++ oy = i - m->nmaster;
++ ox = stairdirection ? n - i - 1 : (stairsamesize ? i - m->nmaster : 0);
++ ow = stairsamesize ? n - m->nmaster - 1 : n - i - 1;
++ oh = stairsamesize ? ow : i - m->nmaster;
++ resize(c,
++ m->wx + mw + (ox * stairpx) + m->gappx,
++ m->wy + (oy * stairpx) + m->gappx,
++ m->ww - mw - (2 * c->bw) - (ow * stairpx) - (2 * m->gappx),
++ m->wh - (2 * c->bw) - (oh * stairpx) - (2 * m->gappx),
++ 0);
++ }
++ }
++}
++
+ void
+ tag(const Arg *arg)
+ {
+--
+2.36.0
diff --git a/dwm.suckless.org/patches/stairs/index.md b/dwm.suckless.org/patches/stairs/index.md
new file mode 100644
index 00000000..15d66fe4
--- /dev/null
+++ b/dwm.suckless.org/patches/stairs/index.md
_AT_@ -0,0 +1,52 @@
+stairs layout
+=============
+
+Description
+-----------
+`stairs` is a dwm layout which is similar to [deck](/patches/deck),
+but the clients in the stack area are arranged like stairs.
+
+This layout can be modified using the 3 variables provided in `config.h`:
+`stairpx`, `stairdirection` and `stairsamesize`.
+
+If you have the [fullgaps](/patches/fullgaps) patch applied,
+apply the `stairs-fullgaps` variant to get gaps.
+
+ +-------------+--------+----------------+
+ | | | |
+ | | +--| S1 |
+ | | |S2| |
+ | | +--| | |
+ | | |S3| | |
+ | M |--| | +----------------+
+ | |S4| | | |
+ | | | +-----------------+ |
+ | | | | |
+ | | +------------------+ |
+ | | | |
+ +-------------+-------------------+-----+
+ stairsamesize = 1
+
+ +-------------+--------+----------------+
+ | | | |
+ | | +--| S1 |
+ | | |S2| |
+ | | +--| | |
+ | | |S3| | |
+ | M |--| | | |
+ | |S4| | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ | | | | | |
+ +-------------+--+--+--+----------------+
+ stairsamesize = 0
+
+Download
+--------
+* [dwm-stairs-20220430-8b48e30.diff](dwm-stairs-20220430-8b48e30.diff)
+* [dwm-stairs-fullgaps-20220430-8b48e30.diff](dwm-stairs-fullgaps-20220430-8b48e30.diff)
+
+Authors
+-------
+* Ehsan Ghorbannezhad - <ehsan_AT_disroot.org>
Received on Sat Apr 30 2022 - 20:16:00 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 30 2022 - 20:24:47 CEST