From b868ff812b09ebfd8f5f41cd5e7ff21914bd3dc3 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 24 May 2026 07:47:30 +0800 Subject: [PATCH] opt: remember and restore size percent in fair and grid layout --- src/layout/arrange.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/layout/arrange.h b/src/layout/arrange.h index e452708b..8c331aa0 100644 --- a/src/layout/arrange.h +++ b/src/layout/arrange.h @@ -1,10 +1,11 @@ void save_old_size_per(Monitor *m) { Client *c = NULL; - wl_list_for_each(c, &clients, link) { if (VISIBLEON(c, m) && ISTILED(c)) { c->old_master_inner_per = c->master_inner_per; c->old_stack_inner_per = c->stack_inner_per; + c->old_grid_col_per = c->grid_col_per; + c->old_grid_row_per = c->grid_row_per; } } } @@ -32,13 +33,24 @@ void restore_size_per(Monitor *m, Client *c) { const Layout *current_layout = m->pertag->ltidxs[m->pertag->curtag]; if (current_layout->id == SCROLLER || - current_layout->id == VERTICAL_SCROLLER || current_layout->id == GRID || - current_layout->id == FAIR || current_layout->id == VERTICAL_FAIR || - current_layout->id == VERTICAL_GRID || current_layout->id == DECK || + current_layout->id == VERTICAL_SCROLLER || current_layout->id == DECK || current_layout->id == VERTICAL_DECK || current_layout->id == MONOCLE) { return; } + if (current_layout->id == GRID || current_layout->id == VERTICAL_GRID || + current_layout->id == FAIR || current_layout->id == VERTICAL_FAIR) { + wl_list_for_each(fc, &clients, link) { + if (VISIBLEON(fc, m) && ISTILED(fc)) { + if (fc->old_grid_col_per > 0.0f) + fc->grid_col_per = fc->old_grid_col_per; + if (fc->old_grid_row_per > 0.0f) + fc->grid_row_per = fc->old_grid_row_per; + } + } + return; + } + if (current_layout->id == CENTER_TILE) { wl_list_for_each(fc, &clients, link) { if (VISIBLEON(fc, m) && ISTILED(fc) && !c->ismaster) {