From 9f8109182a7d173d2a2cb30c089a7e7b9ffe0a5e Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Tue, 25 Mar 2025 02:24:32 +0100 Subject: [PATCH] cfact patch for snail layout --- dwl.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dwl.c b/dwl.c index 4f8c493..37aa935 100644 --- a/dwl.c +++ b/dwl.c @@ -2699,10 +2699,10 @@ snail(Monitor *m) * Split the previous horizontally and put the current window on the right */ } else if (dir == WLR_DIRECTION_RIGHT) { - c->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2, .y = prev->geom.y, - .width = prev->geom.width / 2, .height = prev->geom.height}; + c->geom = (struct wlr_box){.x = prev->geom.x + (int)(prev->cweight / (prev->cweight + c->cweight) * prev->geom.width), .y = prev->geom.y, + .width = (int)(c->cweight / (c->cweight + prev->cweight) * prev->geom.width), .height = prev->geom.height}; prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y, - .width = prev->geom.width / 2, .height = prev->geom.height}; + .width = (int)(prev->cweight / (prev->cweight + c->cweight) * prev->geom.width), .height = prev->geom.height}; /* * If it's a stack window or the first narrow window in the master * area, put the next one below it @@ -2713,28 +2713,28 @@ snail(Monitor *m) * Split the previous vertically and put the current window below it */ } else if (dir == WLR_DIRECTION_DOWN) { - c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2, - .width = prev->geom.width, .height = prev->geom.height / 2}; + c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + (int)(prev->cweight / (prev->cweight + c->cweight) * prev->geom.height), + .width = prev->geom.width, .height = (int)(c->cweight / (c->cweight + prev->cweight) * prev->geom.height)}; prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y, - .width = prev->geom.width, .height = prev->geom.height / 2}; + .width = prev->geom.width, .height = (int)(prev->cweight / (prev->cweight + c->cweight) * prev->geom.height)}; dir = WLR_DIRECTION_LEFT; /* * Split the previous horizontally and put the current window on the left */ } else if (dir == WLR_DIRECTION_LEFT) { c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y, - .width = prev->geom.width / 2, .height = prev->geom.height}; - prev->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2, .y = prev->geom.y, - .width = prev->geom.width / 2, .height = prev->geom.height}; + .width = (int)(c->cweight / (c->cweight + prev->cweight) * prev->geom.width), .height = prev->geom.height}; + prev->geom = (struct wlr_box){.x = prev->geom.x + (int)(c->cweight / (c->cweight + prev->cweight) * prev->geom.width), .y = prev->geom.y, + .width = (int)(prev->cweight / (prev->cweight + c->cweight) * prev->geom.width), .height = prev->geom.height}; dir = WLR_DIRECTION_UP; /* * Split the previous vertically and put the current window above it */ } else { c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y, - .width = prev->geom.width, .height = prev->geom.height / 2}; - prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2, - .width = prev->geom.width, .height = prev->geom.height / 2}; + .width = prev->geom.width, .height = (int)(c->cweight / (c->cweight + prev->cweight) * prev->geom.height)}; + prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + (int)(c->cweight / (c->cweight + prev->cweight) * prev->geom.height), + .width = prev->geom.width, .height = (int)(prev->cweight / (prev->cweight + c->cweight) * prev->geom.height)}; dir = WLR_DIRECTION_RIGHT; } i++; -- 2.49.0