From 45b752920ef8fa6cda5fa78064c0d4aaf8b734a2 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Thu, 18 Jun 2026 14:37:14 +0800 Subject: [PATCH] opt: Eliminate cumulative monocle layout deviations --- src/layout/horizontal.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index 4b8fa29d..7adf7f91 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -587,8 +587,13 @@ void monocle(Monitor *m) { m->w.height - 2 * cur_gappov - 2 * cur_gapiv - titlebar_height; int title_area_width = m->w.width - 2 * cur_gappoh; - int tw = (title_area_width - (n - 1) * cur_gapih) / n; + + int total_gaps = (n - 1) * cur_gapih; + int base_width = (title_area_width - total_gaps) / n; + int remainder = (title_area_width - total_gaps) % n; + int title_x = m->w.x + cur_gappoh; + int idx = 0; wl_list_for_each(c, &clients, link) { if (!VISIBLEON(c, m) || !ISFAKETILED(c)) @@ -606,8 +611,11 @@ void monocle(Monitor *m) { geom.height = main_height; client_tile_resize(c, geom, 0); + int tw = base_width + (idx < remainder ? 1 : 0); global_draw_titlebar(c, title_x, title_y, tw, titlebar_height); + title_x += tw + cur_gapih; + idx++; } }