From 095439425e64f2567f141d5d941178b148ef0d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= Date: Sun, 12 Oct 2025 11:44:26 -0300 Subject: [PATCH] decklayout --- config.def.h | 2 ++ dwl.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/config.def.h b/config.def.h index 95c2afa..cc846eb 100644 --- a/config.def.h +++ b/config.def.h @@ -34,6 +34,7 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[E]", deck }, }; /* monitors */ @@ -139,6 +140,7 @@ 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_a, setlayout, {.v = &layouts[3]} }, { 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 12f441e..227004f 100644 --- a/dwl.c +++ b/dwl.c @@ -278,6 +278,7 @@ static void destroylayersurfacenotify(struct wl_listener *listener, void *data); static void destroylock(SessionLock *lock, int unlocked); static void destroylocksurface(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data); +static void deck(Monitor *m); static void destroypointerconstraint(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data); static void destroykeyboardgroup(struct wl_listener *listener, void *data); @@ -1837,6 +1838,66 @@ monocle(Monitor *m) wlr_scene_node_raise_to_top(&c->scene->node); } +void +deck(Monitor *m) +{ + unsigned int mw, my; + int i, n = 0; + Client *c; + + /* count tiled clients */ + wl_list_for_each(c, &clients, link) + + /* if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) */ + if (VISIBLEON(c, m) && !c->isfloating) + n++; + if (n == 0) + return; + + /* set master width */ + if (n > m->nmaster) + mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; + else + mw = m->w.width; + + /* update layout symbol with number of stack windows */ + /* use the following rules to count only the windows on the deck + if (n > m->nmaster) + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster); + else + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); */ + + /* or this one to count all windows on the tag */ + snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); + + i = my = 0; + wl_list_for_each(c, &clients, link) { + /* if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) */ + if (!VISIBLEON(c, m) || c->isfloating) + continue; + + if (i < m->nmaster) { + /* master clients */ + resize(c, (struct wlr_box){ + .x = m->w.x, + .y = m->w.y + my, + .width = mw, + .height = (m->w.height - my) / (MIN(n, m->nmaster) - i) + }, 0); + my += c->geom.height; + } else { + /* deck clients: overlap in stack area */ + resize(c, (struct wlr_box){ + .x = m->w.x + mw, + .y = m->w.y, + .width = m->w.width - mw, + .height = m->w.height + }, 0); + } + i++; + } +} + void motionabsolute(struct wl_listener *listener, void *data) { -- 2.51.0