centeredmaster: update to 0.7

This commit is contained in:
Nikita Ivanov 2025-02-15 23:08:20 +01:00
parent 07fe3cf50e
commit f1ed83eaeb
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
2 changed files with 39 additions and 20 deletions

View File

@ -24,10 +24,10 @@ With one and two clients in master respectively this results in:
### Download
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/centeredmaster)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster.patch)
- [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)
- [0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/0f4e40fee49d1b8b430778e241b29496ae3b3b70/centeredmaster/centeredmaster.patch)
### Authors
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
- [wochap](https://codeberg.org/wochap)
- [Nikita Ivanov](https://github.com/NikitaIvanovV)

View File

@ -1,19 +1,39 @@
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
From b1ca46930756b59c1ebba0b8c7871b85ff84f62f Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Sat, 8 Feb 2025 16:10:25 +0100
Subject: [PATCH] Add centeredmaster layout
inspiration: https://github.com/djpohly/dwl/wiki/centeredmaster
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 || ||
|| || || || || || || ||
|+--------++--------++--------+| |+--------++--------++--------+|
+------------------------------+ +------------------------------+
---
config.def.h | 2 ++
dwl.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
dwl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8847e58..cfc6e62 100644
index 22d2171..9a3b0c5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@ -21,7 +41,7 @@ index 8847e58..cfc6e62 100644
};
/* monitors */
@@ -134,6 +135,7 @@ static const Key keys[] = {
@@ -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]} },
@ -30,10 +50,10 @@ index 8847e58..cfc6e62 100644
{ 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
index def2562..c2456dd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -248,6 +248,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
@@ -251,6 +251,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);
@ -41,15 +61,14 @@ index bf763df..0e84ccf 100644
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)
@@ -649,6 +650,68 @@ 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;
+ int i, n, h, mw, mx, my, oty, ety, tw;
+ Client *c;
+
+ n = 0;
@ -67,7 +86,7 @@ index bf763df..0e84ccf 100644
+
+ 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);
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
+ tw = m->w.width - mw;
+
+ if (n - m->nmaster > 1) {
@ -112,5 +131,5 @@ index bf763df..0e84ccf 100644
chvt(const Arg *arg)
{
--
2.43.2
2.48.1