mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2026-06-11 10:23:19 +00:00
dwl-patches overhaul
Eliminated wiki. Individual patches have a README.md explanation in their own subdirectory. Simplified submission of new patches and maintenance of existing patches. Instructions page (README.md autodisplayed) is now at https://codeberg.org/dwl/dwl-patches/
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
### Description
|
||||
This is a port of centeredmaster patch for dwm: <https://dwm.suckless.org/patches/centeredmaster>
|
||||
|
||||
centeredmaster centers the nmaster area on screen, using mfact * monitor
|
||||
width & height, with the stacked windows distributed to the left and
|
||||
right. It can be selected with `Alt+c`.
|
||||
|
||||
With one and two clients in master respectively this results in:
|
||||
|
||||
```
|
||||
+------------------------------+ +------------------------------+
|
||||
|+--------++--------++--------+| |+--------++--------++--------+|
|
||||
|| || || || || || || ||
|
||||
|| || || || || || M1 || ||
|
||||
|| || || || || || || ||
|
||||
|| S2 || M || S1 || || |+--------+| ||
|
||||
|| || || || || |+--------+| ||
|
||||
|| || || || || || || ||
|
||||
|| || || || || || M2 || ||
|
||||
|| || || || || || || ||
|
||||
|+--------++--------++--------+| |+--------++--------++--------+|
|
||||
+------------------------------+ +------------------------------+
|
||||
```
|
||||
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/centeredmaster)
|
||||
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/b104a580a80ebaf9f7e8917fe574e3e97ddd019a/centeredmaster/centeredmaster.patch)
|
||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/0f4e40fee49d1b8b430778e241b29496ae3b3b70/centeredmaster/centeredmaster.patch)
|
||||
|
||||
### Authors
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
- [Nikita Ivanov](https://github.com/NikitaIvanovV)
|
||||
@@ -0,0 +1,116 @@
|
||||
From a9d47325283a55fd299de5bbbab5ab195840c7ca Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Thu, 11 Apr 2024 16:42:25 -0500
|
||||
Subject: [PATCH] implement centeredmaster layout
|
||||
|
||||
inspiration: https://github.com/djpohly/dwl/wiki/centeredmaster
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 66 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8847e58..cfc6e62 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 },
|
||||
+ { "|M|", centeredmaster },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -134,6 +135,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|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bf763df..0e84ccf 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -248,6 +248,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(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);
|
||||
@@ -628,6 +629,69 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
event->time_msec, event->button, event->state);
|
||||
}
|
||||
|
||||
+void
|
||||
+centeredmaster(Monitor *m)
|
||||
+{
|
||||
+ unsigned int h, mw, mx, my, oty, ety, tw;
|
||||
+ int i, n;
|
||||
+ 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 */
|
||||
+ 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 */
|
||||
+ mw = ROUND(m->nmaster ? 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)
|
||||
{
|
||||
--
|
||||
2.43.2
|
||||
|
||||
Reference in New Issue
Block a user