mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2026-05-06 08:23:24 +00:00
Add centeredmaster_always setting
Credits: @metalcranium
This commit is contained in:
parent
4e2adff067
commit
8809817422
@ -22,6 +22,8 @@ With one and two clients in master respectively this results in:
|
|||||||
+------------------------------+ +------------------------------+
|
+------------------------------+ +------------------------------+
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Version 0.8 includes `centeredmaster_always` setting to always center a window
|
||||||
|
even if only 1 window is visible on a tag.
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster-0.8.patch)
|
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster-0.8.patch)
|
||||||
@ -32,3 +34,4 @@ With one and two clients in master respectively this results in:
|
|||||||
### Authors
|
### Authors
|
||||||
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
|
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
|
||||||
- [wochap](https://codeberg.org/wochap)
|
- [wochap](https://codeberg.org/wochap)
|
||||||
|
- [metalcranium](https://codeberg.org/metalcranium)
|
||||||
|
|||||||
@ -1,18 +1,26 @@
|
|||||||
From 1fb8c15bb02c50279a5ccbd410dc1293abb747f3 Mon Sep 17 00:00:00 2001
|
From d3d0000c3e2baa8c2a4633581186f768c909667a Mon Sep 17 00:00:00 2001
|
||||||
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
||||||
Date: Sat, 8 Feb 2025 16:10:25 +0100
|
Date: Mon, 13 Apr 2026 18:24:17 +0200
|
||||||
Subject: [PATCH] Add centeredmaster layout
|
Subject: [PATCH] Add centeredmaster layout
|
||||||
|
|
||||||
---
|
---
|
||||||
config.def.h | 2 ++
|
config.def.h | 3 +++
|
||||||
dwl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
dwl.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
2 files changed, 65 insertions(+)
|
2 files changed, 76 insertions(+)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index 8a6eda0..70954cc 100644
|
index 8a6eda0..15cbe32 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
|
@@ -7,6 +7,7 @@
|
||||||
|
static const int sloppyfocus = 1; /* 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);
|
||||||
|
static const float bordercolor[] = COLOR(0x444444ff);
|
||||||
|
static const float focuscolor[] = COLOR(0x005577ff);
|
||||||
|
@@ -33,6 +34,7 @@ static const Layout layouts[] = {
|
||||||
{ "[]=", tile },
|
{ "[]=", tile },
|
||||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||||
{ "[M]", monocle },
|
{ "[M]", monocle },
|
||||||
@ -20,7 +28,7 @@ index 8a6eda0..70954cc 100644
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* monitors */
|
/* monitors */
|
||||||
@@ -135,6 +136,7 @@ static const Key keys[] = {
|
@@ -135,6 +137,7 @@ static const Key keys[] = {
|
||||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||||
@ -29,7 +37,7 @@ index 8a6eda0..70954cc 100644
|
|||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index 44f3ad9..bf859b0 100644
|
index 44f3ad9..98ba318 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -248,6 +248,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
@@ -248,6 +248,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||||
@ -40,7 +48,7 @@ index 44f3ad9..bf859b0 100644
|
|||||||
static void chvt(const Arg *arg);
|
static void chvt(const Arg *arg);
|
||||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
@@ -672,6 +673,68 @@ buttonpress(struct wl_listener *listener, void *data)
|
@@ -672,6 +673,78 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||||
event->time_msec, event->button, event->state);
|
event->time_msec, event->button, event->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,15 +66,25 @@ index 44f3ad9..bf859b0 100644
|
|||||||
+ return;
|
+ return;
|
||||||
+
|
+
|
||||||
+ /* initialize areas */
|
+ /* initialize areas */
|
||||||
+ mw = m->w.width;
|
+ if (centeredmaster_always) {
|
||||||
+ mx = 0;
|
+ mw = m->w.width / 2;
|
||||||
|
+ mx = m->w.width / 4;
|
||||||
|
+ } else {
|
||||||
|
+ mw = m->w.width;
|
||||||
|
+ mx = 0;
|
||||||
|
+ }
|
||||||
+ my = 0;
|
+ my = 0;
|
||||||
+ tw = mw;
|
+ tw = mw;
|
||||||
+
|
+
|
||||||
+ if (n > m->nmaster) {
|
+ if (n > m->nmaster) {
|
||||||
+ /* go mfact box in the center if more than nmaster clients */
|
+ /* go mfact box in the center if more than nmaster clients */
|
||||||
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
+ if (centeredmaster_always) {
|
||||||
+ tw = m->w.width - mw;
|
+ 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) {
|
+ if (n - m->nmaster > 1) {
|
||||||
+ /* only one client */
|
+ /* only one client */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user