diff options
author | Joe <rbo@gmx.us> | 2025-03-02 15:46:23 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2025-03-02 15:46:23 +0100 |
commit | 806cd1209feb78f7b09b0be471a3b4afd02f4994 (patch) | |
tree | 8418657e53d1a37fb5e97da8889c361fafca63f9 | |
parent | rlimit (diff) | |
download | dwl-806cd1209feb78f7b09b0be471a3b4afd02f4994.tar.gz dwl-806cd1209feb78f7b09b0be471a3b4afd02f4994.tar.bz2 dwl-806cd1209feb78f7b09b0be471a3b4afd02f4994.tar.xz dwl-806cd1209feb78f7b09b0be471a3b4afd02f4994.tar.zst dwl-806cd1209feb78f7b09b0be471a3b4afd02f4994.zip |
bstacked
-rw-r--r-- | config.def.h | 11 | ||||
-rw-r--r-- | dwl.c | 84 | ||||
-rw-r--r-- | patches/applied/bottomstack.patch | 140 |
3 files changed, 232 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h index ef6bf0b..03661dc 100644 --- a/config.def.h +++ b/config.def.h @@ -119,6 +119,8 @@ const char *spnews[] = {"n", "alacritty", "--title", "spnews", "-e", "nb", NULL static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, + { "TTT", bstack }, + { "===", bstackhoriz }, { "###", gaplessgrid }, { "[M]", monocle }, { "><>", NULL }, /* no layout function means floating behavior */ @@ -262,9 +264,12 @@ static const Key keys[] = { { MODKEY, XKB_KEY_o, winview, {0}}, { MODKEY, XKB_KEY_q, killclient, {0} }, { MODKEY, XKB_KEY_s, setlayout, {.v = &layouts[0]} }, - { MODKEY, XKB_KEY_v, setlayout, {.v = &layouts[1]} }, - { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XKB_KEY_n, setlayout, {.v = &layouts[3]} }, + { MODKEY, XKB_KEY_z, setlayout, {.v = &layouts[0]} }, + { MODKEY, XKB_KEY_x, setlayout, {.v = &layouts[1]} }, + { MODKEY|SHIFT, XKB_KEY_X, setlayout, {.v = &layouts[2]} }, + { MODKEY, XKB_KEY_v, setlayout, {.v = &layouts[3]} }, + { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[4]} }, + { MODKEY, XKB_KEY_n, setlayout, {.v = &layouts[5]} }, { MODKEY|SHIFT, XKB_KEY_space, setlayout, {0} }, { MODKEY, XKB_KEY_space, togglefloating, {0} }, { MODKEY, XKB_KEY_f, togglefullscreen, {0} }, @@ -61,6 +61,7 @@ #include <wlr/types/wlr_xdg_output_v1.h> #include <wlr/types/wlr_xdg_shell.h> #include <wlr/interfaces/wlr_buffer.h> +#include <wlr/util/box.h> #include <wlr/util/log.h> #include <wlr/util/region.h> #include <xkbcommon/xkbcommon.h> @@ -293,6 +294,8 @@ static void arrangelayer(Monitor *m, struct wl_list *list, static void arrangelayers(Monitor *m); static void axisnotify(struct wl_listener *listener, void *data); static bool baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); static void bufdestroy(struct wlr_buffer *buffer); static bool bufdatabegin(struct wlr_buffer *buffer, uint32_t flags, void **data, uint32_t *format, size_t *stride); @@ -758,6 +761,87 @@ baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy) return true; } +static void +bstack(Monitor *m) +{ + int w, h, mh, mx, tx, ty, tw; + int i, n = 0; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n++; + if (n == 0) + return; + + if (n > m->nmaster) { + mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0); + tw = m->w.width / (n - m->nmaster); + ty = m->w.y + mh; + } else { + mh = m->w.height; + tw = m->w.width; + ty = m->w.y; + } + + i = mx = 0; + tx = m-> w.x; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || c->isfloating) + continue; + if (i < m->nmaster) { + w = (m->w.width - mx) / (MIN(n, m->nmaster) - i); + resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0); + mx += c->geom.width; + } else { + h = m->w.height - mh; + resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = tw, .height = h }, 0); + if (tw != m->w.width) + tx += c->geom.width; + } + i++; + } +} + +static void +bstackhoriz(Monitor *m) { + int w, mh, mx, tx, ty, th; + int i, n = 0; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n ++; + if (n == 0) + return; + + if (n > m->nmaster) { + mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0); + th = (m->w.height - mh) / (n - m->nmaster); + ty = m->w.y + mh; + } else { + th = mh = m->w.height; + ty = m->w.y; + } + + i = mx = 0; + tx = m-> w.x; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c,m) || c->isfloating) + continue; + if (i < m->nmaster) { + w = (m->w.width - mx) / (MIN(n, m->nmaster) - i); + resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0); + mx += c->geom.width; + } else { + resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = m->w.width, .height = th }, 0); + if (th != m->w.height) + ty += c->geom.height; + } + i++; + } +} + void bufdestroy(struct wlr_buffer *wlr_buffer) { diff --git a/patches/applied/bottomstack.patch b/patches/applied/bottomstack.patch new file mode 100644 index 0000000..c2b9331 --- /dev/null +++ b/patches/applied/bottomstack.patch @@ -0,0 +1,140 @@ +From b352fb08f40b1ee2d8c4748be4922df711e3aaa9 Mon Sep 17 00:00:00 2001 +From: wochap <gean.marroquin@gmail.com> +Date: Fri, 5 Jul 2024 10:44:29 -0500 +Subject: [PATCH] implement bottomstack + +--- + config.def.h | 4 +++ + dwl.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 88 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 22d2171..5aac3e9 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -34,6 +34,8 @@ static const Layout layouts[] = { + { "[]=", tile }, + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "TTT", bstack }, ++ { "===", bstackhoriz }, + }; + + /* monitors */ +@@ -139,6 +141,8 @@ static const Key keys[] = { + { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} }, ++ { MODKEY, XKB_KEY_u, setlayout, {.v = &layouts[3]} }, ++ { MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[4]} }, + { MODKEY, XKB_KEY_space, setlayout, {0} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, + { MODKEY, XKB_KEY_e, togglefullscreen, {0} }, +diff --git a/dwl.c b/dwl.c +index dc0437e..5648d5f 100644 +--- a/dwl.c ++++ b/dwl.c +@@ -57,6 +57,7 @@ + #include <wlr/types/wlr_xdg_decoration_v1.h> + #include <wlr/types/wlr_xdg_output_v1.h> + #include <wlr/types/wlr_xdg_shell.h> ++#include <wlr/util/box.h> + #include <wlr/util/log.h> + #include <wlr/util/region.h> + #include <xkbcommon/xkbcommon.h> +@@ -351,6 +352,8 @@ static Monitor *xytomon(double x, double y); + static void xytonode(double x, double y, struct wlr_surface **psurface, + Client **pc, LayerSurface **pl, double *nx, double *ny); + static void zoom(const Arg *arg); ++static void bstack(Monitor *m); ++static void bstackhoriz(Monitor *m); + + /* variables */ + static const char broken[] = "broken"; +@@ -3160,3 +3163,84 @@ main(int argc, char *argv[]) + usage: + die("Usage: %s [-v] [-d] [-s startup command]", argv[0]); + } ++ ++static void ++bstack(Monitor *m) ++{ ++ int w, h, mh, mx, tx, ty, tw; ++ int i, n = 0; ++ Client *c; ++ ++ wl_list_for_each(c, &clients, link) ++ if (VISIBLEON(c, m) && !c->isfloating) ++ n++; ++ if (n == 0) ++ return; ++ ++ if (n > m->nmaster) { ++ mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0); ++ tw = m->w.width / (n - m->nmaster); ++ ty = m->w.y + mh; ++ } else { ++ mh = m->w.height; ++ tw = m->w.width; ++ ty = m->w.y; ++ } ++ ++ i = mx = 0; ++ tx = m-> w.x; ++ wl_list_for_each(c, &clients, link) { ++ if (!VISIBLEON(c, m) || c->isfloating) ++ continue; ++ if (i < m->nmaster) { ++ w = (m->w.width - mx) / (MIN(n, m->nmaster) - i); ++ resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0); ++ mx += c->geom.width; ++ } else { ++ h = m->w.height - mh; ++ resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = tw, .height = h }, 0); ++ if (tw != m->w.width) ++ tx += c->geom.width; ++ } ++ i++; ++ } ++} ++ ++static void ++bstackhoriz(Monitor *m) { ++ int w, mh, mx, tx, ty, th; ++ int i, n = 0; ++ Client *c; ++ ++ wl_list_for_each(c, &clients, link) ++ if (VISIBLEON(c, m) && !c->isfloating) ++ n ++; ++ if (n == 0) ++ return; ++ ++ if (n > m->nmaster) { ++ mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0); ++ th = (m->w.height - mh) / (n - m->nmaster); ++ ty = m->w.y + mh; ++ } else { ++ th = mh = m->w.height; ++ ty = m->w.y; ++ } ++ ++ i = mx = 0; ++ tx = m-> w.x; ++ wl_list_for_each(c, &clients, link) { ++ if (!VISIBLEON(c,m) || c->isfloating) ++ continue; ++ if (i < m->nmaster) { ++ w = (m->w.width - mx) / (MIN(n, m->nmaster) - i); ++ resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0); ++ mx += c->geom.width; ++ } else { ++ resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = m->w.width, .height = th }, 0); ++ if (th != m->w.height) ++ ty += c->geom.height; ++ } ++ i++; ++ } ++} +-- +2.45.1 |