diff options
| author | Alexander Leonhardt <equinox.salexander@gmail.com> | |
|---|---|---|
| 2026-09-05 12:13:59 +0200 | ||
| committer | Alexander Leonhardt <equinox.salexander@gmail.com> | |
| 2026-09-05 12:13:59 +0200 | ||
| commit | 50cee7bb2f244a68eedc9c7c21dc2cef48d76bba (patch) | |
| tree | 3be4ebda2d264e851c606cabc741349c310fe28e | |
| parent | 42b361d1b27b8f482a263eb2851bfdcf6d3d5e8a (diff) | |
| parent | d457393be06f1a6b0e2e0818508d342ec267ef75 (diff) | |
| download | dwl-50cee7bb2f244a68eedc9c7c21dc2cef48d76bba.tar.gz dwl-50cee7bb2f244a68eedc9c7c21dc2cef48d76bba.tar.bz2 dwl-50cee7bb2f244a68eedc9c7c21dc2cef48d76bba.zip | |
Merge branch 'centeredmaster' into merged
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | config.def.h | 5 | ||||
| -rw-r--r-- | dwl.c | 73 | ||||
| -rwxr-xr-x | make_release.sh | 1 |
4 files changed, 79 insertions, 2 deletions
@@ -6,7 +6,7 @@ include config.mk # flags for compiling DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \ -DVERSION=\"$(VERSION)\" $(XWAYLAND) -DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \ +DWLDEVCFLAGS = -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \ -Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \ -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \ -Wfloat-conversion diff --git a/config.def.h b/config.def.h index 3ab5404..3430d29 100644 --- a/config.def.h +++ b/config.def.h @@ -7,11 +7,12 @@ static const int sloppyfocus = 0; /* focus follows mouse */ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ static const unsigned int borderpx = 1; /* border pixel of windows */ +static const int centeredmaster_always = 0; /* always center even if only 1 window */ +static const float rootcolor[] = COLOR(0x222222ff); /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 0; /* 0 means bottom bar */ static const char *fonts[] = {"monospace:size=10"}; -static const float rootcolor[] = COLOR(0x222222ff); static const float unfocuseddim[] = COLOR(0x00000033); /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */ @@ -49,6 +50,7 @@ static const Layout layouts[] = { { "[]=", tile }, { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "|M|", centeredmaster }, }; /* monitors */ @@ -154,6 +156,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_c, setlayout, {.v = &layouts[3]} }, { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY, XKB_KEY_o, menu, {.v = &menus[0]} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, @@ -289,6 +289,7 @@ static void bufdataend(struct wlr_buffer *buffer); static Buffer *bufmon(Monitor *m); static void bufrelease(struct wl_listener *listener, void *data); static void buttonpress(struct wl_listener *listener, void *data); +static void centeredmaster(Monitor *m); static void chvt(const Arg *arg); static void checkidleinhibitor(struct wlr_surface *exclude); static void cleanup(void); @@ -847,6 +848,78 @@ buttonpress(struct wl_listener *listener, void *data) } void +centeredmaster(Monitor *m) +{ + int i, n, h, mw, mx, my, oty, ety, tw; + Client *c; + + n = 0; + wl_list_for_each(c, &clients, link) + if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) + n++; + if (n == 0) + return; + + /* initialize areas */ + if (centeredmaster_always) { + mw = m->w.width / 2; + mx = m->w.width / 4; + } else { + mw = m->w.width; + mx = 0; + } + my = 0; + tw = mw; + + if (n > m->nmaster) { + /* go mfact box in the center if more than nmaster clients */ + if (centeredmaster_always) { + mw = m->nmaster ? (int)roundf(m->w.width / 2) : 0; + tw = mw / 2; + } else { + mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; + tw = m->w.width - mw; + } + + if (n - m->nmaster > 1) { + /* only one client */ + mx = (m->w.width - mw) / 2; + tw = (m->w.width - mw) / 2; + } + } + + i = 0; + oty = 0; + ety = 0; + wl_list_for_each(c, &clients, link) { + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) + continue; + if (i < m->nmaster) { + /* nmaster clients are stacked vertically, in the center + * of the screen */ + h = (m->w.height - my) / (MIN(n, m->nmaster) - i); + resize(c, (struct wlr_box){.x = m->w.x + mx, .y = m->w.y + my, .width = mw, + .height = h}, 0); + my += c->geom.height; + } else { + /* stack clients are stacked vertically */ + if ((i - m->nmaster) % 2) { + h = (m->w.height - ety) / ( (1 + n - i) / 2); + resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + ety, .width = tw, + .height = h}, 0); + ety += c->geom.height; + } else { + h = (m->w.height - oty) / ((1 + n - i) / 2); + resize(c, (struct wlr_box){.x = m->w.x + mx + mw, .y = m->w.y + oty, .width = tw, + .height = h}, 0); + oty += c->geom.height; + } + } + i++; + } +} + +void chvt(const Arg *arg) { wlr_session_change_vt(session, arg->ui); diff --git a/make_release.sh b/make_release.sh new file mode 100755 index 0000000..9c0aa65 --- /dev/null +++ b/make_release.sh @@ -0,0 +1 @@ +sudo CFLAGS="-O3 -march=native -mtune=native -ffast-math" make install |