From dde321282059f2d8bb79667267207edd012f6d8a Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 6 Nov 2023 00:32:24 +0000 Subject: Added "deck" layout patch --- config.h | 16 +++++----- dwm-deck-6.2.diff | 77 +++++++++++++++++++++++++++++++++++++++++++++++ dwm-deck-tilegap-6.1.diff | 55 +++++++++++++++++++++++++++++++++ dwm.c | 29 ++++++++++++++++++ 4 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 dwm-deck-6.2.diff create mode 100644 dwm-deck-tilegap-6.1.diff diff --git a/config.h b/config.h index c4a3c05..34e597e 100644 --- a/config.h +++ b/config.h @@ -70,13 +70,14 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const Layout layouts[] = { /* symbol arrange function */ - { "[T]=", tile }, /* first entry is default */ - { "=", NULL }, /* no layout function means floating behavior */ + { "[T]=", tile }, /* first entry is default */ + { "=", NULL }, /* no layout function means floating behavior */ { "{M}", monocle }, { "|M|", centeredmaster }, { ">M>", centeredfloatingmaster }, { "[@]", spiral }, - { "[\\]", dwindle }, + { "[\\]", dwindle }, + { "[D]", deck }, }; /* key definitions */ @@ -118,10 +119,11 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[0]} }, //tiling { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} }, //floating { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[2]} }, //monocle - { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} }, //cmonocle - { MODKEY|ShiftMask, XK_o, setlayout, {.v = &layouts[4]} }, //cfmonocle - { MODKEY|ShiftMask, XK_s, setlayout, {.v = &layouts[5]} }, //fib-spiral - { MODKEY|ShiftMask, XK_d, setlayout, {.v = &layouts[6]} }, //fib-spiral + { MODKEY|ShiftMask, XK_n, setlayout, {.v = &layouts[3]} }, //cmonocle + { MODKEY|ShiftMask, XK_b, setlayout, {.v = &layouts[4]} }, //cfmonocle + { MODKEY|ShiftMask, XK_y, setlayout, {.v = &layouts[5]} }, //fib-spiral + { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[6]} }, //fib-spiral + { MODKEY|ShiftMask, XK_i, setlayout, {.v = &layouts[7]} }, //deck { MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY, XK_space, togglefloating, {0} }, { MODKEY, XK_m, focusmon, {.i = -1 } }, diff --git a/dwm-deck-6.2.diff b/dwm-deck-6.2.diff new file mode 100644 index 0000000..b5afed7 --- /dev/null +++ b/dwm-deck-6.2.diff @@ -0,0 +1,77 @@ +From a071b060a1b9b94bcb167b988cf7774ceb870aad Mon Sep 17 00:00:00 2001 +From: Jack Bird +Date: Mon, 2 Aug 2021 18:44:05 +0100 +Subject: [PATCH] deck patch works with 6.2 + +--- + config.def.h | 2 ++ + dwm.c | 26 ++++++++++++++++++++++++++ + 2 files changed, 28 insertions(+) + +diff --git a/config.def.h b/config.def.h +index a2ac963..d865e18 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -42,6 +42,7 @@ static const Layout layouts[] = { + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "[D]", deck }, + }; + + /* key definitions */ +@@ -77,6 +78,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_r, 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 5e4d494..c67ff91 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -157,6 +157,7 @@ static void configure(Client *c); + static void configurenotify(XEvent *e); + static void configurerequest(XEvent *e); + static Monitor *createmon(void); ++static void deck(Monitor *m); + static void destroynotify(XEvent *e); + static void detach(Client *c); + static void detachstack(Client *c); +@@ -655,6 +656,31 @@ destroynotify(XEvent *e) + unmanage(c, 1); + } + ++void ++deck(Monitor *m) { ++ unsigned int i, n, h, mw, my; ++ 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; ++ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster); ++ } ++ 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), False); ++ my += HEIGHT(c); ++ } ++ else ++ resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False); ++} ++ + void + detach(Client *c) + { +-- +2.32.0 + diff --git a/dwm-deck-tilegap-6.1.diff b/dwm-deck-tilegap-6.1.diff new file mode 100644 index 0000000..30b6e83 --- /dev/null +++ b/dwm-deck-tilegap-6.1.diff @@ -0,0 +1,55 @@ +From a9e442ec18683e2255ffef74404c283bbb0b6381 Mon Sep 17 00:00:00 2001 +From: aleks +Date: Thu, 23 May 2019 23:27:59 +0200 +Subject: [PATCH] Make deck-patch work with the tilegap-patch + +Apply this patch on top of the deck-patch to make it work with the +tilegap-patch. +--- + dwm.c | 18 ++++++++++-------- + 1 file changed, 10 insertions(+), 8 deletions(-) + +diff --git a/dwm.c b/dwm.c +index 5b68242..1c17891 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -656,7 +656,7 @@ createmon(void) + + void + deck(Monitor *m) { +- unsigned int i, n, h, mw, my; ++ unsigned int i, n, h, mw, my, ns; + Client *c; + + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); +@@ -665,18 +665,20 @@ deck(Monitor *m) { + + if(n > m->nmaster) { + mw = m->nmaster ? m->ww * m->mfact : 0; ++ ns = m->nmaster > 0 ? 2 : 1; + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster); +- } +- else ++ } else { + mw = m->ww; +- for(i = my = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ ns = 1; ++ } ++ for(i = 0, my = gappx, 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), False); +- my += HEIGHT(c); ++ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx; ++ resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False); ++ my += HEIGHT(c) + gappx; + } + else +- resize(c, m->wx + mw, m->wy, m->ww - mw - (2*c->bw), m->wh - (2*c->bw), False); ++ resize(c, m->wx + mw + gappx/ns, m->wy + gappx, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, m->wh - (2*c->bw) - 2*gappx, False); + } + + void +-- +2.21.0 + diff --git a/dwm.c b/dwm.c index 84a5040..9d2f368 100644 --- a/dwm.c +++ b/dwm.c @@ -164,6 +164,7 @@ static void configurenotify(XEvent *e); static void configurerequest(XEvent *e); static void copyvalidchars(char *text, char *rawtext); static Monitor *createmon(void); +static void deck(Monitor *m); static void destroynotify(XEvent *e); static void detach(Client *c); static void detachstack(Client *c); @@ -744,6 +745,34 @@ destroynotify(XEvent *e) unmanage(c, 1); } +void +deck(Monitor *m) { + unsigned int i, n, h, mw, my, ns; + 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; + ns = m->nmaster > 0 ? 2 : 1; + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster); + } else { + mw = m->ww; + ns = 1; + } + for(i = 0, my = gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if(i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gappx; + resize(c, m->wx + gappx, m->wy + my, mw - (2*c->bw) - gappx*(5-ns)/2, h - (2*c->bw), False); + if (my + HEIGHT(c) < m->wh) + my += HEIGHT(c) + m->gappx; + } + else + resize(c, m->wx + mw + gappx/ns, m->wy + gappx, m->ww - mw - (2*c->bw) - gappx*(5-ns)/2, m->wh - (2*c->bw) - 2*gappx, False); +} + void detach(Client *c) { -- cgit v1.2.3-13-gbd6f