opt: more simple size percent keep logic

This commit is contained in:
DreamMaoMao 2026-05-24 12:13:30 +08:00
parent 373bbf90a0
commit e6ae14ec25
5 changed files with 232 additions and 305 deletions

View file

@ -49,3 +49,12 @@ static void finish_exchange_arrange_and_focus(Client *c1, Client *c2,
wl_list_remove(&c2->flink); wl_list_remove(&c2->flink);
wl_list_insert(&c1->flink, &c2->flink); wl_list_insert(&c1->flink, &c2->flink);
} }
void client_tile_resize(Client *c, struct wlr_box geo, int32_t interact) {
if (!ISSCROLLTILED(c))
return;
if (!c->isfullscreen && !c->ismaximizescreen) {
resize(c, geo, interact);
}
}

View file

@ -1,98 +1,3 @@
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;
}
}
}
void restore_size_per(Monitor *m, Client *c) {
Client *fc = NULL;
if (!m || !c)
return;
if (!m->wlr_output->enabled)
return;
wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) {
fc->old_ismaster = fc->ismaster;
}
}
c->old_master_inner_per = c->master_inner_per;
c->old_stack_inner_per = c->stack_inner_per;
pre_caculate_before_arrange(m, false, false, true);
const Layout *current_layout = m->pertag->ltidxs[m->pertag->curtag];
if (current_layout->id == SCROLLER ||
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) {
set_size_per(m, fc);
}
}
return;
}
// it is possible that the current floating window is moved to another tag,
// but the tag has not executed save_old_size_per
// so it must be judged whether their old size values are initial values
if (!c->ismaster && c->old_stack_inner_per < 1.0 &&
c->old_stack_inner_per > 0.0f && c->stack_inner_per < 1.0 &&
c->stack_inner_per > 0.0f) {
c->stack_inner_per = (1.0 - c->stack_inner_per) *
c->old_stack_inner_per /
(1.0 - c->old_stack_inner_per);
}
if (c->ismaster && c->old_master_inner_per < 1.0 &&
c->old_master_inner_per > 0.0f && c->master_inner_per < 1.0 &&
c->master_inner_per > 0.0f) {
c->master_inner_per = (1.0 - c->master_inner_per) *
c->old_master_inner_per /
(1.0 - c->old_master_inner_per);
}
wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc) && fc != c && !fc->ismaster &&
fc->old_ismaster && fc->old_stack_inner_per < 1.0 &&
fc->old_stack_inner_per > 0.0f && fc->stack_inner_per < 1.0 &&
fc->stack_inner_per > 0.0f) {
fc->stack_inner_per = (1.0 - fc->stack_inner_per) *
fc->old_stack_inner_per /
(1.0 - fc->old_stack_inner_per);
fc->old_ismaster = false;
}
}
}
void set_size_per(Monitor *m, Client *c) { void set_size_per(Monitor *m, Client *c) {
Client *fc = NULL; Client *fc = NULL;
bool found = false; bool found = false;
@ -1114,7 +1019,7 @@ void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
if (m->pertag->ltidxs[m->pertag->curtag]->id != CENTER_TILE) { if (m->pertag->ltidxs[m->pertag->curtag]->id != CENTER_TILE) {
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISFAKETILED(c)) {
if (total_master_inner_percent > 0.0 && i < nmasters) { if (total_master_inner_percent > 0.0 && i < nmasters) {
c->ismaster = true; c->ismaster = true;
@ -1137,7 +1042,7 @@ void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
} }
} else { } else {
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISFAKETILED(c)) {
if (total_master_inner_percent > 0.0 && i < nmasters) { if (total_master_inner_percent > 0.0 && i < nmasters) {
c->ismaster = true; c->ismaster = true;
@ -1196,6 +1101,7 @@ void pre_caculate_before_arrange(Monitor *m, bool want_animation,
m->visible_clients = 0; m->visible_clients = 0;
m->visible_tiling_clients = 0; m->visible_tiling_clients = 0;
m->visible_scroll_tiling_clients = 0; m->visible_scroll_tiling_clients = 0;
m->visible_fake_tiling_clients = 0;
uint32_t tag = m->pertag->curtag; uint32_t tag = m->pertag->curtag;
struct TagScrollerState *st = m->pertag->scroller_state[tag]; struct TagScrollerState *st = m->pertag->scroller_state[tag];
@ -1239,6 +1145,10 @@ void pre_caculate_before_arrange(Monitor *m, bool want_animation,
m->visible_scroll_tiling_clients++; m->visible_scroll_tiling_clients++;
} }
} }
if (ISFAKETILED(c)) {
m->visible_fake_tiling_clients++;
}
} }
} }
@ -1250,7 +1160,7 @@ void pre_caculate_before_arrange(Monitor *m, bool want_animation,
if (c->mon == m) { if (c->mon == m) {
if (VISIBLEON(c, m)) { if (VISIBLEON(c, m)) {
if (ISTILED(c)) { if (ISFAKETILED(c)) {
if (i < nmasters) { if (i < nmasters) {
master_num++; master_num++;
total_master_inner_percent += c->master_inner_per; total_master_inner_percent += c->master_inner_per;

View file

@ -10,21 +10,24 @@ void deck(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappov = enablegaps ? m->gappov : 0; int32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappih = cur_gappih = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; ? 0
cur_gappoh = : cur_gappih;
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
cur_gappov = ? 0
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; : cur_gappoh;
cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappov;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
if (n == 0) if (n == 0)
return; return;
wl_list_for_each(fc, &clients, link) { wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) if (VISIBLEON(fc, m) && ISFAKETILED(fc))
break; break;
} }
@ -40,12 +43,12 @@ void deck(Monitor *m) {
i = my = 0; i = my = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
if (i < nmasters) { if (i < nmasters) {
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
// Master area clients // Master area clients
resize( client_tile_resize(
c, c,
(struct wlr_box){.x = m->w.x + cur_gappoh, (struct wlr_box){.x = m->w.x + cur_gappoh,
.y = m->w.y + cur_gappov + my, .y = m->w.y + cur_gappov + my,
@ -57,7 +60,8 @@ void deck(Monitor *m) {
} else { } else {
// Stack area clients // Stack area clients
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
resize(c, client_tile_resize(
c,
(struct wlr_box){.x = m->w.x + mw + cur_gappoh + cur_gappih, (struct wlr_box){.x = m->w.x + mw + cur_gappoh + cur_gappih,
.y = m->w.y + cur_gappov, .y = m->w.y + cur_gappov,
.width = m->w.width - mw - 2 * cur_gappoh - .width = m->w.width - mw - 2 * cur_gappoh -
@ -79,7 +83,7 @@ void center_tile(Monitor *m) {
int32_t master_num = 0; int32_t master_num = 0;
int32_t stack_num = 0; int32_t stack_num = 0;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n; master_num = n > master_num ? master_num : n;
@ -90,7 +94,7 @@ void center_tile(Monitor *m) {
// 获取第一个可见的平铺客户端用于主区域宽度百分比 // 获取第一个可见的平铺客户端用于主区域宽度百分比
wl_list_for_each(fc, &clients, link) { wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) if (VISIBLEON(fc, m) && ISFAKETILED(fc))
break; break;
} }
@ -101,14 +105,18 @@ void center_tile(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙 int32_t cur_gappoh = enablegaps ? m->gappoh : 0; // 外部水平间隙
// 智能间隙处理 // 智能间隙处理
cur_gappiv = cur_gappiv = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; ? 0
cur_gappih = : cur_gappiv;
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih = config.smartgaps && m->visible_fake_tiling_clients == 1
cur_gappov = ? 0
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; : cur_gappih;
cur_gappoh = cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; ? 0
: cur_gappov;
cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappoh;
int32_t nmasters = m->pertag->nmasters[m->pertag->curtag]; int32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
@ -174,7 +182,7 @@ void center_tile(Monitor *m) {
i = 0; i = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
if (i < nmasters) { if (i < nmasters) {
@ -196,7 +204,7 @@ void center_tile(Monitor *m) {
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} }
resize(c, client_tile_resize(c,
(struct wlr_box){.x = m->w.x + mx, (struct wlr_box){.x = m->w.x + mx,
.y = m->w.y + my, .y = m->w.y + my,
.width = mw, .width = mw,
@ -233,7 +241,7 @@ void center_tile(Monitor *m) {
stack_x = m->w.x + mx + mw + cur_gappih * ie; stack_x = m->w.x + mx + mw + cur_gappih * ie;
} }
resize(c, client_tile_resize(c,
(struct wlr_box){.x = stack_x, (struct wlr_box){.x = stack_x,
.y = m->w.y + ety, .y = m->w.y + ety,
.width = tw, .width = tw,
@ -266,7 +274,7 @@ void center_tile(Monitor *m) {
int32_t stack_x = m->w.x + mx + mw + cur_gappih * ie; int32_t stack_x = m->w.x + mx + mw + cur_gappih * ie;
resize(c, client_tile_resize(c,
(struct wlr_box){.x = stack_x, (struct wlr_box){.x = stack_x,
.y = m->w.y + ety, .y = m->w.y + ety,
.width = tw, .width = tw,
@ -294,7 +302,7 @@ void center_tile(Monitor *m) {
} }
int32_t stack_x = m->w.x + cur_gappoh; int32_t stack_x = m->w.x + cur_gappoh;
resize(c, client_tile_resize(c,
(struct wlr_box){.x = stack_x, (struct wlr_box){.x = stack_x,
.y = m->w.y + oty, .y = m->w.y + oty,
.width = tw, .width = tw,
@ -316,7 +324,7 @@ void tile(Monitor *m) {
int32_t master_num = 0; int32_t master_num = 0;
int32_t stack_num = 0; int32_t stack_num = 0;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n; master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
@ -329,18 +337,22 @@ void tile(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0; int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = cur_gappiv = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; ? 0
cur_gappih = : cur_gappiv;
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih = config.smartgaps && m->visible_fake_tiling_clients == 1
cur_gappov = ? 0
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; : cur_gappih;
cur_gappoh = cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; ? 0
: cur_gappov;
cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappoh;
wl_list_for_each(fc, &clients, link) { wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) if (VISIBLEON(fc, m) && ISFAKETILED(fc))
break; break;
} }
@ -365,7 +377,7 @@ void tile(Monitor *m) {
float slave_surplus_ratio = 1.0; float slave_surplus_ratio = 1.0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
@ -384,7 +396,7 @@ void tile(Monitor *m) {
cur_gappiv * ie * (r - 1)); cur_gappiv * ie * (r - 1));
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} }
resize(c, client_tile_resize(c,
(struct wlr_box){.x = m->w.x + cur_gappoh, (struct wlr_box){.x = m->w.x + cur_gappoh,
.y = m->w.y + my, .y = m->w.y + my,
.width = mw - cur_gappih * ie, .width = mw - cur_gappih * ie,
@ -410,7 +422,8 @@ void tile(Monitor *m) {
// wlr_log(WLR_ERROR, "stack_inner_per: %f", c->stack_inner_per); // wlr_log(WLR_ERROR, "stack_inner_per: %f", c->stack_inner_per);
resize(c, client_tile_resize(
c,
(struct wlr_box){.x = m->w.x + mw + cur_gappoh, (struct wlr_box){.x = m->w.x + mw + cur_gappoh,
.y = m->w.y + ty, .y = m->w.y + ty,
.width = m->w.width - mw - 2 * cur_gappoh, .width = m->w.width - mw - 2 * cur_gappoh,
@ -430,7 +443,7 @@ void right_tile(Monitor *m) {
int32_t master_num = 0; int32_t master_num = 0;
int32_t stack_num = 0; int32_t stack_num = 0;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n; master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
@ -443,18 +456,22 @@ void right_tile(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0; int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappiv = cur_gappiv = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; ? 0
cur_gappih = : cur_gappiv;
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappih; cur_gappih = config.smartgaps && m->visible_fake_tiling_clients == 1
cur_gappov = ? 0
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; : cur_gappih;
cur_gappoh = cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; ? 0
: cur_gappov;
cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappoh;
wl_list_for_each(fc, &clients, link) { wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) if (VISIBLEON(fc, m) && ISFAKETILED(fc))
break; break;
} }
@ -479,7 +496,7 @@ void right_tile(Monitor *m) {
float slave_surplus_ratio = 1.0; float slave_surplus_ratio = 1.0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
@ -498,8 +515,9 @@ void right_tile(Monitor *m) {
cur_gappiv * ie * (r - 1)); cur_gappiv * ie * (r - 1));
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} }
resize(c, client_tile_resize(c,
(struct wlr_box){.x = m->w.x + m->w.width - mw - cur_gappoh + (struct wlr_box){.x = m->w.x + m->w.width - mw -
cur_gappoh +
cur_gappih * ie, cur_gappih * ie,
.y = m->w.y + my, .y = m->w.y + my,
.width = mw - cur_gappih * ie, .width = mw - cur_gappih * ie,
@ -525,7 +543,8 @@ void right_tile(Monitor *m) {
// wlr_log(WLR_ERROR, "stack_inner_per: %f", c->stack_inner_per); // wlr_log(WLR_ERROR, "stack_inner_per: %f", c->stack_inner_per);
resize(c, client_tile_resize(
c,
(struct wlr_box){.x = m->w.x + cur_gappoh, (struct wlr_box){.x = m->w.x + cur_gappoh,
.y = m->w.y + ty, .y = m->w.y + ty,
.width = m->w.width - mw - 2 * cur_gappoh, .width = m->w.width - mw - 2 * cur_gappoh,
@ -545,19 +564,21 @@ monocle(Monitor *m) {
int32_t cur_gappov = enablegaps ? m->gappov : 0; int32_t cur_gappov = enablegaps ? m->gappov : 0;
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
cur_gappoh = cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; ? 0
cur_gappov = : cur_gappoh;
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappov;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
geom.x = m->w.x + cur_gappoh; geom.x = m->w.x + cur_gappoh;
geom.y = m->w.y + cur_gappov; geom.y = m->w.y + cur_gappov;
geom.width = m->w.width - 2 * cur_gappoh; geom.width = m->w.width - 2 * cur_gappoh;
geom.height = m->w.height - 2 * cur_gappov; geom.height = m->w.height - 2 * cur_gappov;
resize(c, geom, 0); client_tile_resize(c, geom, 0);
} }
if ((c = focustop(m))) if ((c = focustop(m)))
wlr_scene_node_raise_to_top(&c->scene->node); wlr_scene_node_raise_to_top(&c->scene->node);
@ -570,14 +591,12 @@ void grid(Monitor *m) {
int32_t cols, rows, overcols; int32_t cols, rows, overcols;
Client *c = NULL; Client *c = NULL;
n = 0; n = 0;
int32_t target_gappo = int32_t target_gappo = enablegaps ? config.gappoh : 0;
enablegaps ? m->isoverview ? config.overviewgappo : config.gappoh : 0; int32_t target_gappi = enablegaps ? config.gappih : 0;
int32_t target_gappi = float single_width_ratio = 0.9;
enablegaps ? m->isoverview ? config.overviewgappi : config.gappih : 0; float single_height_ratio = 0.9;
float single_width_ratio = m->isoverview ? 0.7 : 0.9;
float single_height_ratio = m->isoverview ? 0.8 : 0.9;
n = m->isoverview ? m->visible_clients : m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
if (n == 0) if (n == 0)
return; return;
@ -587,14 +606,15 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) ||
ISFAKETILED(c))) {
cw = (m->w.width - 2 * target_gappo) * single_width_ratio; cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
ch = (m->w.height - 2 * target_gappo) * single_height_ratio; ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
c->geom.x = m->w.x + (m->w.width - cw) / 2; c->geom.x = m->w.x + (m->w.width - cw) / 2;
c->geom.y = m->w.y + (m->w.height - ch) / 2; c->geom.y = m->w.y + (m->w.height - ch) / 2;
c->geom.width = cw; c->geom.width = cw;
c->geom.height = ch; c->geom.height = ch;
resize(c, c->geom, 0); client_tile_resize(c, c->geom, 0);
return; return;
} }
} }
@ -608,7 +628,8 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) ||
ISFAKETILED(c))) {
if (i < 2) if (i < 2)
col_pers[i] = col_pers[i] =
(c->grid_col_per > 0.0f) ? c->grid_col_per : 1.0f; (c->grid_col_per > 0.0f) ? c->grid_col_per : 1.0f;
@ -626,7 +647,8 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) ||
ISFAKETILED(c))) {
c->grid_col_idx = i; c->grid_col_idx = i;
c->grid_row_idx = 0; c->grid_row_idx = 0;
c->grid_col_per = col_pers[i]; c->grid_col_per = col_pers[i];
@ -645,7 +667,7 @@ void grid(Monitor *m) {
c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo; c->geom.y = m->w.y + (m->w.height - ch) / 2 + target_gappo;
c->geom.width = cw; c->geom.width = cw;
c->geom.height = ch; c->geom.height = ch;
resize(c, c->geom, 0); client_tile_resize(c, c->geom, 0);
i++; i++;
} }
} }
@ -673,7 +695,7 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISFAKETILED(c))) {
int32_t c_idx = i % cols; int32_t c_idx = i % cols;
int32_t r_idx = i / cols; int32_t r_idx = i / cols;
if (r_idx == 0) if (r_idx == 0)
@ -701,7 +723,7 @@ void grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISFAKETILED(c))) {
int32_t c_idx = i % cols; int32_t c_idx = i % cols;
int32_t r_idx = i / cols; int32_t r_idx = i / cols;
@ -746,7 +768,7 @@ void grid(Monitor *m) {
c->geom.y = (int32_t)fl_cy; c->geom.y = (int32_t)fl_cy;
c->geom.width = (int32_t)fl_cw; c->geom.width = (int32_t)fl_cw;
c->geom.height = (int32_t)fl_ch; c->geom.height = (int32_t)fl_ch;
resize(c, c->geom, 0); client_tile_resize(c, c->geom, 0);
i++; i++;
} }
} }
@ -756,7 +778,7 @@ void fair(Monitor *m) {
int32_t i, n = 0; int32_t i, n = 0;
Client *c = NULL; Client *c = NULL;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
if (n == 0) if (n == 0)
return; return;
@ -787,7 +809,7 @@ void fair(Monitor *m) {
Client *arr[n]; Client *arr[n];
int32_t arr_idx = 0; int32_t arr_idx = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISFAKETILED(c)) {
arr[arr_idx++] = c; arr[arr_idx++] = c;
if (arr_idx >= n) if (arr_idx >= n)
break; // 安全边界 break; // 安全边界
@ -917,7 +939,7 @@ void fair(Monitor *m) {
fl_cx = col_x[col_idx]; fl_cx = col_x[col_idx];
fl_cw = col_w[col_idx]; fl_cw = col_w[col_idx];
resize(c, client_tile_resize(c,
(struct wlr_box){.x = (int32_t)fl_cx, (struct wlr_box){.x = (int32_t)fl_cx,
.y = (int32_t)fl_cy, .y = (int32_t)fl_cy,
.width = (int32_t)fl_cw, .width = (int32_t)fl_cw,

View file

@ -6,7 +6,7 @@ void vertical_tile(Monitor *m) {
int32_t master_num = 0; int32_t master_num = 0;
int32_t stack_num = 0; int32_t stack_num = 0;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
master_num = m->pertag->nmasters[m->pertag->curtag]; master_num = m->pertag->nmasters[m->pertag->curtag];
master_num = n > master_num ? master_num : n; master_num = n > master_num ? master_num : n;
stack_num = n - master_num; stack_num = n - master_num;
@ -20,16 +20,16 @@ void vertical_tile(Monitor *m) {
int32_t cur_gapov = enablegaps ? m->gappov : 0; int32_t cur_gapov = enablegaps ? m->gappov : 0;
cur_gapih = cur_gapih =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih; config.smartgaps && m->visible_fake_tiling_clients == 1 ? 0 : cur_gapih;
cur_gapiv = cur_gapiv =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv; config.smartgaps && m->visible_fake_tiling_clients == 1 ? 0 : cur_gapiv;
cur_gapoh = cur_gapoh =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapoh; config.smartgaps && m->visible_fake_tiling_clients == 1 ? 0 : cur_gapoh;
cur_gapov = cur_gapov =
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapov; config.smartgaps && m->visible_fake_tiling_clients == 1 ? 0 : cur_gapov;
wl_list_for_each(fc, &clients, link) { wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) if (VISIBLEON(fc, m) && ISFAKETILED(fc))
break; break;
} }
@ -55,7 +55,7 @@ void vertical_tile(Monitor *m) {
float slave_surplus_ratio = 1.0; float slave_surplus_ratio = 1.0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
if (i < m->pertag->nmasters[m->pertag->curtag]) { if (i < m->pertag->nmasters[m->pertag->curtag]) {
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i; r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
@ -73,7 +73,7 @@ void vertical_tile(Monitor *m) {
cur_gapih * ie * (r - 1)); cur_gapih * ie * (r - 1));
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} }
resize(c, client_tile_resize(c,
(struct wlr_box){.x = m->w.x + mx, (struct wlr_box){.x = m->w.x + mx,
.y = m->w.y + cur_gapov, .y = m->w.y + cur_gapov,
.width = w, .width = w,
@ -96,7 +96,8 @@ void vertical_tile(Monitor *m) {
c->master_mfact_per = mfact; c->master_mfact_per = mfact;
} }
resize(c, client_tile_resize(
c,
(struct wlr_box){.x = m->w.x + tx, (struct wlr_box){.x = m->w.x + tx,
.y = m->w.y + mh + cur_gapov, .y = m->w.y + mh + cur_gapov,
.width = w, .width = w,
@ -120,21 +121,24 @@ void vertical_deck(Monitor *m) {
int32_t cur_gappoh = enablegaps ? m->gappoh : 0; int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
int32_t cur_gappov = enablegaps ? m->gappov : 0; int32_t cur_gappov = enablegaps ? m->gappov : 0;
cur_gappiv = cur_gappiv = config.smartgaps && m->visible_fake_tiling_clients == 1
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappiv; ? 0
cur_gappoh = : cur_gappiv;
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappoh; cur_gappoh = config.smartgaps && m->visible_fake_tiling_clients == 1
cur_gappov = ? 0
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gappov; : cur_gappoh;
cur_gappov = config.smartgaps && m->visible_fake_tiling_clients == 1
? 0
: cur_gappov;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
if (n == 0) if (n == 0)
return; return;
wl_list_for_each(fc, &clients, link) { wl_list_for_each(fc, &clients, link) {
if (VISIBLEON(fc, m) && ISTILED(fc)) if (VISIBLEON(fc, m) && ISFAKETILED(fc))
break; break;
} }
@ -149,10 +153,10 @@ void vertical_deck(Monitor *m) {
i = mx = 0; i = mx = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || !ISTILED(c)) if (!VISIBLEON(c, m) || !ISFAKETILED(c))
continue; continue;
if (i < nmasters) { if (i < nmasters) {
resize( client_tile_resize(
c, c,
(struct wlr_box){.x = m->w.x + cur_gappoh + mx, (struct wlr_box){.x = m->w.x + cur_gappoh + mx,
.y = m->w.y + cur_gappov, .y = m->w.y + cur_gappov,
@ -162,12 +166,13 @@ void vertical_deck(Monitor *m) {
0); 0);
mx += c->geom.width; mx += c->geom.width;
} else { } else {
resize(c, client_tile_resize(
c,
(struct wlr_box){.x = m->w.x + cur_gappoh, (struct wlr_box){.x = m->w.x + cur_gappoh,
.y = m->w.y + mh + cur_gappov + cur_gappiv, .y = m->w.y + mh + cur_gappov + cur_gappiv,
.width = m->w.width - 2 * cur_gappoh, .width = m->w.width - 2 * cur_gappoh,
.height = m->w.height - mh - .height = m->w.height - mh - 2 * cur_gappov -
2 * cur_gappov - cur_gappiv}, cur_gappiv},
0); 0);
if (c == focustop(m)) if (c == focustop(m))
wlr_scene_node_raise_to_top(&c->scene->node); wlr_scene_node_raise_to_top(&c->scene->node);
@ -188,7 +193,7 @@ void vertical_grid(Monitor *m) {
float single_width_ratio = m->isoverview ? 0.7 : 0.9; float single_width_ratio = m->isoverview ? 0.7 : 0.9;
float single_height_ratio = m->isoverview ? 0.8 : 0.9; float single_height_ratio = m->isoverview ? 0.8 : 0.9;
n = m->isoverview ? m->visible_clients : m->visible_tiling_clients; n = m->isoverview ? m->visible_clients : m->visible_fake_tiling_clients;
if (n == 0) if (n == 0)
return; return;
@ -197,14 +202,15 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) ||
ISFAKETILED(c))) {
ch = (m->w.height - 2 * target_gappo) * single_height_ratio; ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
cw = (m->w.width - 2 * target_gappo) * single_width_ratio; cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
c->geom.x = m->w.x + (m->w.width - cw) / 2; c->geom.x = m->w.x + (m->w.width - cw) / 2;
c->geom.y = m->w.y + (m->w.height - ch) / 2; c->geom.y = m->w.y + (m->w.height - ch) / 2;
c->geom.width = cw; c->geom.width = cw;
c->geom.height = ch; c->geom.height = ch;
resize(c, c->geom, 0); client_tile_resize(c, c->geom, 0);
return; return;
} }
} }
@ -218,7 +224,8 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) ||
ISFAKETILED(c))) {
if (i < 2) if (i < 2)
row_pers[i] = row_pers[i] =
(c->grid_row_per > 0.0f) ? c->grid_row_per : 1.0f; (c->grid_row_per > 0.0f) ? c->grid_row_per : 1.0f;
@ -235,7 +242,8 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) ||
ISFAKETILED(c))) {
c->grid_col_idx = 0; c->grid_col_idx = 0;
c->grid_row_idx = i; c->grid_row_idx = i;
c->grid_col_per = 1.0f; c->grid_col_per = 1.0f;
@ -254,7 +262,7 @@ void vertical_grid(Monitor *m) {
} }
c->geom.width = cw; c->geom.width = cw;
c->geom.height = ch; c->geom.height = ch;
resize(c, c->geom, 0); client_tile_resize(c, c->geom, 0);
i++; i++;
} }
} }
@ -279,7 +287,7 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISFAKETILED(c))) {
int32_t c_idx = i / rows; int32_t c_idx = i / rows;
int32_t r_idx = i % rows; int32_t r_idx = i % rows;
if (r_idx == 0) if (r_idx == 0)
@ -306,7 +314,7 @@ void vertical_grid(Monitor *m) {
if (c->mon != m) if (c->mon != m)
continue; continue;
if (VISIBLEON(c, m) && !c->isunglobal && if (VISIBLEON(c, m) && !c->isunglobal &&
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) { ((m->isoverview && !client_is_x11_popup(c)) || ISFAKETILED(c))) {
int32_t c_idx = i / rows; int32_t c_idx = i / rows;
int32_t r_idx = i % rows; int32_t r_idx = i % rows;
@ -348,7 +356,7 @@ void vertical_grid(Monitor *m) {
c->geom.y = (int32_t)fl_cy; c->geom.y = (int32_t)fl_cy;
c->geom.width = (int32_t)fl_cw; c->geom.width = (int32_t)fl_cw;
c->geom.height = (int32_t)fl_ch; c->geom.height = (int32_t)fl_ch;
resize(c, c->geom, 0); client_tile_resize(c, c->geom, 0);
i++; i++;
} }
} }
@ -358,7 +366,7 @@ void vertical_fair(Monitor *m) {
int32_t i, n = 0; int32_t i, n = 0;
Client *c = NULL; Client *c = NULL;
n = m->visible_tiling_clients; n = m->visible_fake_tiling_clients;
if (n == 0) if (n == 0)
return; return;
@ -386,7 +394,7 @@ void vertical_fair(Monitor *m) {
Client *arr[n]; Client *arr[n];
int32_t arr_idx = 0; int32_t arr_idx = 0;
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (VISIBLEON(c, m) && ISTILED(c)) { if (VISIBLEON(c, m) && ISFAKETILED(c)) {
arr[arr_idx++] = c; arr[arr_idx++] = c;
if (arr_idx >= n) if (arr_idx >= n)
break; break;
@ -511,7 +519,7 @@ void vertical_fair(Monitor *m) {
fl_cy = row_y[row_idx]; fl_cy = row_y[row_idx];
fl_ch = row_h[row_idx]; fl_ch = row_h[row_idx];
resize(c, client_tile_resize(c,
(struct wlr_box){.x = (int32_t)fl_cx, (struct wlr_box){.x = (int32_t)fl_cx,
.y = (int32_t)fl_cy, .y = (int32_t)fl_cy,
.width = (int32_t)fl_cw, .width = (int32_t)fl_cw,

View file

@ -114,6 +114,9 @@
#define ISSCROLLTILED(A) \ #define ISSCROLLTILED(A) \
(A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \ (A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \
!(A)->isunglobal) !(A)->isunglobal)
#define ISFAKETILED(A) \
(A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \
!(A)->isunglobal)
#define VISIBLEON(C, M) \ #define VISIBLEON(C, M) \
((C) && (M) && (C)->mon == (M) && \ ((C) && (M) && (C)->mon == (M) && \
(((C)->tags & (M)->tagset[(M)->seltags] || (C)->isglobal || \ (((C)->tags & (M)->tagset[(M)->seltags] || (C)->isglobal || \
@ -550,6 +553,7 @@ struct Monitor {
uint32_t visible_clients; uint32_t visible_clients;
uint32_t visible_tiling_clients; uint32_t visible_tiling_clients;
uint32_t visible_scroll_tiling_clients; uint32_t visible_scroll_tiling_clients;
uint32_t visible_fake_tiling_clients;
char last_surface_ws_name[256]; char last_surface_ws_name[256];
struct wlr_ext_workspace_group_handle_v1 *ext_group; struct wlr_ext_workspace_group_handle_v1 *ext_group;
bool iscleanuping; bool iscleanuping;
@ -5374,15 +5378,6 @@ setfloating(Client *c, int32_t floating) {
layers[c->isfloating ? LyrTop : LyrTile]); layers[c->isfloating ? LyrTop : LyrTile]);
} }
if (!c->isfloating && old_floating_state &&
(c->old_stack_inner_per > 0.0f || c->old_master_inner_per > 0.0f)) {
restore_size_per(c->mon, c);
}
if (c->isfloating && !old_floating_state) {
save_old_size_per(c->mon);
}
if (!c->force_fakemaximize) if (!c->force_fakemaximize)
client_set_maximized(c, false); client_set_maximized(c, false);
@ -5435,7 +5430,6 @@ void setmaximizescreen(Client *c, int32_t maximizescreen) {
if (c->mon->isoverview) if (c->mon->isoverview)
return; return;
int32_t old_maximizescreen_state = c->ismaximizescreen;
client_pending_maximized_state(c, maximizescreen); client_pending_maximized_state(c, maximizescreen);
if (maximizescreen) { if (maximizescreen) {
@ -5462,13 +5456,6 @@ void setmaximizescreen(Client *c, int32_t maximizescreen) {
wlr_scene_node_reparent(&c->scene->node, wlr_scene_node_reparent(&c->scene->node,
layers[c->isfloating ? LyrTop : LyrTile]); layers[c->isfloating ? LyrTop : LyrTile]);
if (!c->ismaximizescreen && old_maximizescreen_state) {
restore_size_per(c->mon, c);
}
if (c->ismaximizescreen && !old_maximizescreen_state) {
save_old_size_per(c->mon);
}
if (!c->force_fakemaximize && !c->ismaximizescreen) { if (!c->force_fakemaximize && !c->ismaximizescreen) {
client_set_maximized(c, false); client_set_maximized(c, false);
@ -5499,7 +5486,6 @@ void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自
if (c->mon->isoverview) if (c->mon->isoverview)
return; return;
int32_t old_fullscreen_state = c->isfullscreen;
c->isfullscreen = fullscreen; c->isfullscreen = fullscreen;
client_set_fullscreen(c, fullscreen); client_set_fullscreen(c, fullscreen);
@ -5536,14 +5522,6 @@ void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自
layers[fullscreen || c->isfloating ? LyrTop : LyrTile]); layers[fullscreen || c->isfloating ? LyrTop : LyrTile]);
} }
if (!c->isfullscreen && old_fullscreen_state) {
restore_size_per(c->mon, c);
}
if (c->isfullscreen && !old_fullscreen_state) {
save_old_size_per(c->mon);
}
arrange(c->mon, false, false); arrange(c->mon, false, false);
} }