From f57e898b35bcddf6f2b651cdba2e047741f9f6ac Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Mon, 7 Jul 2025 14:02:00 +0800 Subject: [PATCH] fix: smartgap shouldn't affect by non-tiling window --- src/layout/horizontal.h | 56 +++++++++++++++++++++-------------------- src/layout/vertical.h | 56 +++++++++++++++++++++-------------------- src/maomao.c | 6 +++++ 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index 02a70e5..71022a6 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -6,10 +6,10 @@ void fibonacci(Monitor *mon, int s) { unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0; unsigned int cur_gappov = enablegaps ? mon->gappov : 0; - cur_gappih = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappih; - cur_gappiv = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappoh = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappiv = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappoh = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappov; // Count visible clients wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c)) n++; @@ -28,7 +28,8 @@ void fibonacci(Monitor *mon, int s) { if (!VISIBLEON(c, mon) || !ISTILED(c)) continue; - c->bw = mon->visible_clients == 1 && no_border_when_single && smartgaps + c->bw = mon->visible_tiling_clients == 1 && no_border_when_single && + smartgaps ? 0 : borderpx; if ((i % 2 && nh / 2 > 2 * c->bw) || (!(i % 2) && nw / 2 > 2 * c->bw)) { @@ -146,10 +147,10 @@ void grid(Monitor *m) { if (n == 1) { wl_list_for_each(c, &clients, link) { - c->bw = - m->visible_clients == 1 && no_border_when_single && smartgaps - ? 0 - : borderpx; + c->bw = m->visible_tiling_clients == 1 && no_border_when_single && + smartgaps + ? 0 + : borderpx; if (VISIBLEON(c, m) && !c->isunglobal && ((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) { @@ -170,10 +171,10 @@ void grid(Monitor *m) { ch = (m->w.height - 2 * overviewgappo) * 0.65; i = 0; wl_list_for_each(c, &clients, link) { - c->bw = - m->visible_clients == 1 && no_border_when_single && smartgaps - ? 0 - : borderpx; + c->bw = m->visible_tiling_clients == 1 && no_border_when_single && + smartgaps + ? 0 + : borderpx; if (VISIBLEON(c, m) && !c->isunglobal && ((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) { @@ -218,9 +219,10 @@ void grid(Monitor *m) { // 调整每个客户端的位置和大小 i = 0; wl_list_for_each(c, &clients, link) { - c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps - ? 0 - : borderpx; + c->bw = + m->visible_tiling_clients == 1 && no_border_when_single && smartgaps + ? 0 + : borderpx; if (VISIBLEON(c, m) && !c->isunglobal && ((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) { cx = m->w.x + (i % cols) * (cw + overviewgappi); @@ -247,10 +249,10 @@ void deck(Monitor *m) { unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; - cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih; - cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++; if (n == 0) @@ -310,9 +312,9 @@ void scroller(Monitor *m) { unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; - cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih; - cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; unsigned int max_client_width = m->w.width - 2 * scroller_structs - cur_gappih; @@ -447,10 +449,10 @@ void tile(Monitor *m) { unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; - cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih; - cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; if (n > selmon->pertag->nmasters[selmon->pertag->curtag]) mw = selmon->pertag->nmasters[selmon->pertag->curtag] diff --git a/src/layout/vertical.h b/src/layout/vertical.h index e9875f1..7b8a48c 100644 --- a/src/layout/vertical.h +++ b/src/layout/vertical.h @@ -6,10 +6,10 @@ void vertical_fibonacci(Monitor *mon, int s) { unsigned int cur_gappoh = enablegaps ? mon->gappoh : 0; unsigned int cur_gappov = enablegaps ? mon->gappov : 0; - cur_gappih = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappih; - cur_gappiv = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappoh = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && mon->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappiv = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappoh = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && mon->visible_tiling_clients == 1 ? 0 : cur_gappov; // Count visible clients wl_list_for_each(c, &clients, link) if (VISIBLEON(c, mon) && ISTILED(c)) n++; @@ -28,7 +28,8 @@ void vertical_fibonacci(Monitor *mon, int s) { if (!VISIBLEON(c, mon) || !ISTILED(c)) continue; - c->bw = mon->visible_clients == 1 && no_border_when_single && smartgaps + c->bw = mon->visible_tiling_clients == 1 && no_border_when_single && + smartgaps ? 0 : borderpx; if ((i % 2 && nw / 2 > 2 * c->bw) || (!(i % 2) && nh / 2 > 2 * c->bw)) { @@ -144,10 +145,10 @@ void vertical_grid(Monitor *m) { if (n == 1) { wl_list_for_each(c, &clients, link) { - c->bw = - m->visible_clients == 1 && no_border_when_single && smartgaps - ? 0 - : borderpx; + c->bw = m->visible_tiling_clients == 1 && no_border_when_single && + smartgaps + ? 0 + : borderpx; if (VISIBLEON(c, m) && !c->isunglobal && ((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) { @@ -168,10 +169,10 @@ void vertical_grid(Monitor *m) { cw = (m->w.width - 2 * overviewgappo) * 0.65; i = 0; wl_list_for_each(c, &clients, link) { - c->bw = - m->visible_clients == 1 && no_border_when_single && smartgaps - ? 0 - : borderpx; + c->bw = m->visible_tiling_clients == 1 && no_border_when_single && + smartgaps + ? 0 + : borderpx; if (VISIBLEON(c, m) && !c->isunglobal && ((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) { @@ -213,9 +214,10 @@ void vertical_grid(Monitor *m) { i = 0; wl_list_for_each(c, &clients, link) { - c->bw = m->visible_clients == 1 && no_border_when_single && smartgaps - ? 0 - : borderpx; + c->bw = + m->visible_tiling_clients == 1 && no_border_when_single && smartgaps + ? 0 + : borderpx; if (VISIBLEON(c, m) && !c->isunglobal && ((m->isoverview && !client_should_ignore_focus(c)) || ISTILED(c))) { cx = m->w.x + (i / rows) * (cw + overviewgappi); @@ -242,10 +244,10 @@ void vertical_deck(Monitor *m) { unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; - cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih; - cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; wl_list_for_each(c, &clients, link) if (VISIBLEON(c, m) && ISTILED(c)) n++; if (n == 0) @@ -299,9 +301,9 @@ void vertical_scroller(Monitor *m) { unsigned int cur_gappov = enablegaps ? m->gappov : 0; unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; - cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov; - cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh; + cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; unsigned int max_client_height = m->w.height - 2 * scroller_structs - cur_gappiv; @@ -432,10 +434,10 @@ void vertical_tile(Monitor *m) { unsigned int cur_gappoh = enablegaps ? m->gappoh : 0; unsigned int cur_gappov = enablegaps ? m->gappov : 0; - cur_gappih = smartgaps && m->visible_clients == 1 ? 0 : cur_gappih; - cur_gappiv = smartgaps && m->visible_clients == 1 ? 0 : cur_gappiv; - cur_gappoh = smartgaps && m->visible_clients == 1 ? 0 : cur_gappoh; - cur_gappov = smartgaps && m->visible_clients == 1 ? 0 : cur_gappov; + cur_gappih = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; + cur_gappiv = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; + cur_gappoh = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; + cur_gappov = smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; if (n > selmon->pertag->nmasters[selmon->pertag->curtag]) mh = selmon->pertag->nmasters[selmon->pertag->curtag] diff --git a/src/maomao.c b/src/maomao.c index 137afc1..763daf3 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -413,6 +413,7 @@ struct Monitor { int gamma_lut_changed; int asleep; unsigned int visible_clients; + unsigned int visible_tiling_clients; struct wlr_scene_optimized_blur *blur; char last_surface_ws_name[256]; }; @@ -1472,6 +1473,7 @@ arrange(Monitor *m, bool want_animation) { return; m->visible_clients = 0; + m->visible_tiling_clients = 0; wl_list_for_each(c, &clients, link) { if (c->iskilling) continue; @@ -1489,6 +1491,10 @@ arrange(Monitor *m, bool want_animation) { m->visible_clients++; } + if (ISTILED(c)) { + m->visible_tiling_clients++; + } + if (!c->is_clip_to_hide || !ISTILED(c) || !is_scroller_layout(c->mon)) { c->is_clip_to_hide = false;