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

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

View file

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

View file

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