From b1e221c3655d4984f763ad4ceb293f24fc1798d6 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Fri, 19 Sep 2025 11:34:45 +0800 Subject: [PATCH] opt: optimize scroller_prefer_center judge when kill a client --- src/layout/horizontal.h | 9 +++++---- src/layout/vertical.h | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index ff260e4..62bbfce 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -392,10 +392,11 @@ void scroller(Monitor *m) { if (need_scroller) { if (scroller_focus_center || ((!m->prevsel || - (m->prevsel->scroller_proportion * max_client_width) + - (root_client->scroller_proportion * max_client_width) > - m->w.width - 2 * scroller_structs - cur_gappih) && - ISTILED(m->prevsel) && scroller_prefer_center)) { + (ISTILED(m->prevsel) && + (m->prevsel->scroller_proportion * max_client_width) + + (root_client->scroller_proportion * max_client_width) > + m->w.width - 2 * scroller_structs - cur_gappih)) && + scroller_prefer_center)) { target_geom.x = m->w.x + (m->w.width - target_geom.width) / 2; } else { target_geom.x = root_client->geom.x > m->w.x + (m->w.width) / 2 diff --git a/src/layout/vertical.h b/src/layout/vertical.h index 2c6c289..117275f 100644 --- a/src/layout/vertical.h +++ b/src/layout/vertical.h @@ -379,10 +379,11 @@ void vertical_scroller(Monitor *m) { if (need_scroller) { if (scroller_focus_center || ((!m->prevsel || - (m->prevsel->scroller_proportion * max_client_height) + - (root_client->scroller_proportion * max_client_height) > - m->w.height - 2 * scroller_structs - cur_gappiv) && - ISTILED(m->prevsel) && scroller_prefer_center)) { + (ISTILED(m->prevsel) && + (m->prevsel->scroller_proportion * max_client_height) + + (root_client->scroller_proportion * max_client_height) > + m->w.height - 2 * scroller_structs - cur_gappiv)) && + scroller_prefer_center)) { target_geom.y = m->w.y + (m->w.height - target_geom.height) / 2; } else { target_geom.y = root_client->geom.y > m->w.y + (m->w.height) / 2