1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From e3ad25b5149df936155cb51927f16648a9838bc0 Mon Sep 17 00:00:00 2001
From: estevao <estevao.mendes@acad.ufsm.br>
Date: Thu, 25 Jul 2024 13:20:50 -0300
Subject: [PATCH] cfact patch for centeredmaster layout
---
dwl.c | 42 ++++++++++++++++++++++++++++++++++++++----
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git a/dwl.c b/dwl.c
index 91c1511..37732c0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -654,6 +656,7 @@ void
centeredmaster(Monitor *m)
{
unsigned int h, mw, mx, my, oty, ety, tw;
+ float mweight = 0, ltweight = 0, rtweight = 0;
int i, n;
Client *c;
@@ -672,7 +675,7 @@ centeredmaster(Monitor *m)
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 = roundf(m->nmaster ? m->w.width * m->mfact : 0);
tw = m->w.width - mw;
if (n - m->nmaster > 1) {
@@ -682,6 +685,20 @@ centeredmaster(Monitor *m)
}
}
+ i = 0;
+ wl_list_for_each(c, &clients, link){
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (i < m->nmaster)
+ mweight += c->cweight;
+ else if ( (i - m->nmaster)%2 ){
+ ltweight += c->cweight;
+ }else{
+ rtweight += c->cweight;
+ }
+ i++;
+ }
+
i = 0;
oty = 0;
ety = 0;
@@ -691,22 +708,24 @@ centeredmaster(Monitor *m)
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);
+ h = (m->w.height - my)*(c->cweight/mweight);
resize(c, (struct wlr_box){.x = m->w.x + mx, .y = m->w.y + my, .width = mw,
.height = h}, 0);
my += c->geom.height;
+ mweight -= c->cweight;
} else {
/* stack clients are stacked vertically */
if ((i - m->nmaster) % 2) {
- h = (m->w.height - ety) / ( (1 + n - i) / 2);
+ h = (m->w.height - ety)*(c->cweight/ltweight);
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + ety, .width = tw,
.height = h}, 0);
ety += c->geom.height;
+ ltweight -= c->cweight;
} else {
- h = (m->w.height - oty) / ((1 + n - i) / 2);
+ h = (m->w.height - oty)*(c->cweight/rtweight);
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;
+ rtweight -= c->cweight;
}
}
i++;
--
2.45.2
|