From 7f55299516c3607536e18ee88ec15dc4e4b63b25 Mon Sep 17 00:00:00 2001 From: Abanoub Date: Wed, 21 Jun 2023 18:16:36 +0300 Subject: [PATCH] vertile --- config.def.h | 2 ++ dwl.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/config.def.h b/config.def.h index 447ba00..366f38d 100644 --- a/config.def.h +++ b/config.def.h @@ -24,6 +24,7 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "|v|", vertile }, }; /* monitors */ @@ -123,6 +124,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_T, 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 da3a516..6f2ddd0 100644 --- a/dwl.c +++ b/dwl.c @@ -303,6 +303,7 @@ static void startdrag(struct wl_listener *listener, void *data); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); +static void vertile(Monitor *m); static void togglefloating(const Arg *arg); static void togglefullscreen(const Arg *arg); static void toggletag(const Arg *arg); @@ -2412,6 +2413,40 @@ tile(Monitor *m) } } +void +vertile(Monitor *m) +{ + unsigned int i, n = 0, h, mh, my, ty; + Client *c; + + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating) + n++; + if (n == 0) + return; + + if (n > m->nmaster) + ty = mh = m->nmaster ? m->w.height * m->mfact : 0; + else + ty = mh = m->w.height; + i = my = 0; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) + continue; + if (i < m->nmaster) { + h = ( mh - my ) / (MIN(n, m->nmaster) - i); + resize(c, (struct wlr_box) { .x = m->w.x, .y = m->w.y + my, .width = m->w.width, .height = h }, 0); + my += c->geom.height; + } else { + h = ( m->w.height - ty ) / (n - i); + resize(c, (struct wlr_box) { .x = m->w.x, .y = m->w.y + ty, .width = m->w.width, .height = h }, 0); + ty += c->geom.height; + } + i++; + } +} + + void togglefloating(const Arg *arg) {