diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-25 16:21:52 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-25 16:21:52 +0200 |
commit | c89cda27d36aaff8971905d067e4b89b6337259d (patch) | |
tree | 4bc52e701d4195a56290eebc4c133ca9d489fdef | |
parent | up (diff) | |
download | dwm-c89cda27d36aaff8971905d067e4b89b6337259d.tar.gz dwm-c89cda27d36aaff8971905d067e4b89b6337259d.tar.bz2 dwm-c89cda27d36aaff8971905d067e4b89b6337259d.tar.xz dwm-c89cda27d36aaff8971905d067e4b89b6337259d.tar.zst dwm-c89cda27d36aaff8971905d067e4b89b6337259d.zip |
stairs
-rw-r--r-- | config.def.h | 21 | ||||
-rw-r--r-- | config.h | 21 | ||||
-rw-r--r-- | dwm-stairs-fullgaps-20220430-8b48e30.diff | 98 | ||||
-rw-r--r-- | dwm.c | 38 |
4 files changed, 162 insertions, 16 deletions
diff --git a/config.def.h b/config.def.h index 847cd05..d61d4e6 100644 --- a/config.def.h +++ b/config.def.h @@ -8,6 +8,9 @@ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const int user_bh = 22; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */ static const int focusonwheel = 0; +static const unsigned int stairpx = 20; /* depth of the stairs layout */ +static const int stairdirection = 0; /* 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[] = { "UbuntuMono Nerd Font:size=14" }; static const char dmenufont[] = "monospace:size=11"; static const char col_gray1[] = "#222222"; @@ -64,11 +67,12 @@ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen win static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ + { "TTT", bstack }, + { "===", bstackhoriz }, { "|M|", centeredmaster }, { ">M>", centeredfloatingmaster }, + { "[S]", stairs }, { "[M]", monocle }, - { "TTT", bstack }, - { "===", bstackhoriz }, { "><>", NULL }, /* no layout function means floating behavior */ }; @@ -189,12 +193,13 @@ static Key keys[] = { { METAKEY, XK_Escape, view, {0} }, { MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_s, setlayout, {.v = &layouts[0]} }, /* tile */ - { MODKEY, XK_c, setlayout, {.v = &layouts[1]} }, /* centeredmaster */ - { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, /* centeredfloatingmaster */ - { MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, /* monocle */ - { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[4]} }, /* bottoastack */ - { MODKEY, XK_t, setlayout, {.v = &layouts[5]} }, /* bottomstackhoriz */ - { MODKEY, XK_n, setlayout, {.v = &layouts[6]} }, /* floating */ + { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[1]} }, /* bottoastack */ + { MODKEY, XK_t, setlayout, {.v = &layouts[2]} }, /* bottomstackhoriz */ + { MODKEY, XK_c, setlayout, {.v = &layouts[3]} }, /* centeredmaster */ + { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[4]} }, /* centeredfloatingmaster */ + { MODKEY|ControlMask, XK_s, setlayout, {.v = &layouts[5]} }, /* stairs */ + { MODKEY, XK_m, setlayout, {.v = &layouts[6]} }, /* monocle */ + { MODKEY, XK_n, setlayout, {.v = &layouts[7]} }, /* floating */ { MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY, XK_space, togglefloating, {0} }, { MODKEY, XK_f, togglefullscr, {0} }, @@ -8,6 +8,9 @@ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const int user_bh = 22; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */ static const int focusonwheel = 0; +static const unsigned int stairpx = 20; /* depth of the stairs layout */ +static const int stairdirection = 0; /* 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[] = { "UbuntuMono Nerd Font:size=14" }; static const char dmenufont[] = "monospace:size=11"; static const char col_gray1[] = "#222222"; @@ -64,11 +67,12 @@ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen win static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ + { "TTT", bstack }, + { "===", bstackhoriz }, { "|M|", centeredmaster }, { ">M>", centeredfloatingmaster }, + { "[S]", stairs }, { "[M]", monocle }, - { "TTT", bstack }, - { "===", bstackhoriz }, { "><>", NULL }, /* no layout function means floating behavior */ }; @@ -189,12 +193,13 @@ static Key keys[] = { { METAKEY, XK_Escape, view, {0} }, { MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_s, setlayout, {.v = &layouts[0]} }, /* tile */ - { MODKEY, XK_c, setlayout, {.v = &layouts[1]} }, /* centeredmaster */ - { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, /* centeredfloatingmaster */ - { MODKEY, XK_m, setlayout, {.v = &layouts[3]} }, /* monocle */ - { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[4]} }, /* bottoastack */ - { MODKEY, XK_t, setlayout, {.v = &layouts[5]} }, /* bottomstackhoriz */ - { MODKEY, XK_n, setlayout, {.v = &layouts[6]} }, /* floating */ + { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[1]} }, /* bottoastack */ + { MODKEY, XK_t, setlayout, {.v = &layouts[2]} }, /* bottomstackhoriz */ + { MODKEY, XK_c, setlayout, {.v = &layouts[3]} }, /* centeredmaster */ + { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[4]} }, /* centeredfloatingmaster */ + { MODKEY|ControlMask, XK_s, setlayout, {.v = &layouts[5]} }, /* stairs */ + { MODKEY, XK_m, setlayout, {.v = &layouts[6]} }, /* monocle */ + { MODKEY, XK_n, setlayout, {.v = &layouts[7]} }, /* floating */ { MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY, XK_space, togglefloating, {0} }, { MODKEY, XK_f, togglefullscr, {0} }, diff --git a/dwm-stairs-fullgaps-20220430-8b48e30.diff b/dwm-stairs-fullgaps-20220430-8b48e30.diff new file mode 100644 index 0000000..53e7966 --- /dev/null +++ b/dwm-stairs-fullgaps-20220430-8b48e30.diff @@ -0,0 +1,98 @@ +From 2004db267a9478918699961ab2f3579c2c8113fb Mon Sep 17 00:00:00 2001 +From: Ehsan Ghorbannezhad <ehsan@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 +@@ -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"; +@@ -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 */ +@@ -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 +@@ -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 *); +@@ -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 @@ -253,6 +253,7 @@ static void centeredmaster(Monitor *m); static void centeredfloatingmaster(Monitor *m); static void bstack(Monitor *m); static void bstackhoriz(Monitor *m); +static void stairs(Monitor *m); /* variables */ static const char broken[] = "broken"; @@ -1878,6 +1879,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) { if (selmon->sel && arg->ui & TAGMASK) { |