From f0f2e5a5d333476b91cdb276187446e4b3c9954c Mon Sep 17 00:00:00 2001 From: Palanix Date: Sun, 9 Jul 2023 19:35:19 +0200 Subject: [PATCH] Deck layout --- config.def.h | 2 ++ dwl.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/config.def.h b/config.def.h index db0babc6f..1ad35b0f7 100644 --- a/config.def.h +++ b/config.def.h @@ -33,6 +33,7 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[D]", deck }, }; /* monitors */ @@ -132,6 +133,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|WLR_MODIFIER_SHIFT, XKB_KEY_D, 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 1bfe8cf6f..f7e7fa5c6 100644 --- a/dwl.c +++ b/dwl.c @@ -252,6 +252,7 @@ static void createmon(struct wl_listener *listener, void *data); static void createnotify(struct wl_listener *listener, void *data); static void createpointer(struct wlr_pointer *pointer); static void cursorframe(struct wl_listener *listener, void *data); +static void deck(Monitor *m); static void destroydragicon(struct wl_listener *listener, void *data); static void destroyidleinhibitor(struct wl_listener *listener, void *data); static void destroylayersurfacenotify(struct wl_listener *listener, void *data); @@ -1033,6 +1034,40 @@ cursorframe(struct wl_listener *listener, void *data) wlr_seat_pointer_notify_frame(seat); } +void +deck(Monitor *m) +{ + unsigned int i, n = 0, mw, my; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) + n++; + if (n == 0) + return; + + if (n > m->nmaster) + mw = m->nmaster ? m->w.width * m->mfact : 0; + else + mw = m->w.width; + i = my = 0; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) + continue; + if (i < m->nmaster) { + 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 { + resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y, + .width = m->w.width - mw, .height = m->w.height}, 0); + if (i == m->nmaster) + wlr_scene_node_raise_to_top(&c->scene->node); + } + i++; + } +} + void destroydragicon(struct wl_listener *listener, void *data) {