mirror of
				https://codeberg.org/dwl/dwl-patches.git
				synced 2025-11-04 05:54:20 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			84 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
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
 | 
						|
 |