2025-10-09 13:09:40 +08:00
|
|
|
void vertical_tile(Monitor *m) {
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t i, n = 0, w, r, ie = enablegaps, mh, mx, tx;
|
2025-10-06 14:11:36 +08:00
|
|
|
Client *c = NULL;
|
2025-10-09 13:09:40 +08:00
|
|
|
Client *fc = NULL;
|
|
|
|
|
double mfact = 0;
|
2026-01-03 09:47:49 +08:00
|
|
|
int32_t master_num = 0;
|
|
|
|
|
int32_t stack_num = 0;
|
2025-06-28 12:35:58 +08:00
|
|
|
|
2025-09-09 16:32:15 +08:00
|
|
|
n = m->visible_tiling_clients;
|
2025-10-09 13:09:40 +08:00
|
|
|
master_num = m->pertag->nmasters[m->pertag->curtag];
|
2025-12-07 21:12:45 +08:00
|
|
|
master_num = n > master_num ? master_num : n;
|
2025-10-09 13:09:40 +08:00
|
|
|
stack_num = n - master_num;
|
2025-09-09 16:32:15 +08:00
|
|
|
|
2025-06-28 12:35:58 +08:00
|
|
|
if (n == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t cur_gapih = enablegaps ? m->gappih : 0;
|
|
|
|
|
int32_t cur_gapiv = enablegaps ? m->gappiv : 0;
|
|
|
|
|
int32_t cur_gapoh = enablegaps ? m->gappoh : 0;
|
|
|
|
|
int32_t cur_gapov = enablegaps ? m->gappov : 0;
|
2025-06-28 12:35:58 +08:00
|
|
|
|
2026-03-12 06:49:58 -07:00
|
|
|
cur_gapih =
|
|
|
|
|
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapih;
|
|
|
|
|
cur_gapiv =
|
|
|
|
|
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapiv;
|
|
|
|
|
cur_gapoh =
|
|
|
|
|
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapoh;
|
|
|
|
|
cur_gapov =
|
|
|
|
|
config.smartgaps && m->visible_tiling_clients == 1 ? 0 : cur_gapov;
|
2025-10-09 13:09:40 +08:00
|
|
|
|
|
|
|
|
wl_list_for_each(fc, &clients, link) {
|
|
|
|
|
if (VISIBLEON(fc, m) && ISTILED(fc))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
|
|
|
|
|
: m->pertag->mfacts[m->pertag->curtag];
|
|
|
|
|
|
|
|
|
|
if (n > m->pertag->nmasters[m->pertag->curtag])
|
|
|
|
|
mh = m->pertag->nmasters[m->pertag->curtag]
|
|
|
|
|
? (m->w.height + cur_gapiv * ie) * mfact
|
|
|
|
|
: 0;
|
2025-06-28 12:35:58 +08:00
|
|
|
else
|
2025-10-09 13:09:40 +08:00
|
|
|
mh = m->w.height - 2 * cur_gapov + cur_gapiv * ie;
|
2025-06-28 12:35:58 +08:00
|
|
|
|
2025-10-09 13:09:40 +08:00
|
|
|
i = 0;
|
2025-12-26 08:35:02 +08:00
|
|
|
mx = tx = cur_gapoh;
|
2025-12-09 20:35:21 +08:00
|
|
|
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t master_surplus_width =
|
2025-12-26 08:35:02 +08:00
|
|
|
(m->w.width - 2 * cur_gapoh - cur_gapih * ie * (master_num - 1));
|
2025-12-09 20:35:21 +08:00
|
|
|
float master_surplus_ratio = 1.0;
|
|
|
|
|
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t slave_surplus_width =
|
2025-12-26 08:35:02 +08:00
|
|
|
(m->w.width - 2 * cur_gapoh - cur_gapih * ie * (stack_num - 1));
|
2025-12-09 20:35:21 +08:00
|
|
|
float slave_surplus_ratio = 1.0;
|
|
|
|
|
|
2025-06-28 12:35:58 +08:00
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (!VISIBLEON(c, m) || !ISTILED(c))
|
|
|
|
|
continue;
|
2025-10-09 13:09:40 +08:00
|
|
|
if (i < m->pertag->nmasters[m->pertag->curtag]) {
|
|
|
|
|
r = MIN(n, m->pertag->nmasters[m->pertag->curtag]) - i;
|
|
|
|
|
if (c->master_inner_per > 0.0f) {
|
2025-12-09 20:35:21 +08:00
|
|
|
w = master_surplus_width * c->master_inner_per /
|
|
|
|
|
master_surplus_ratio;
|
|
|
|
|
master_surplus_width = master_surplus_width - w;
|
|
|
|
|
master_surplus_ratio =
|
|
|
|
|
master_surplus_ratio - c->master_inner_per;
|
2025-10-09 13:09:40 +08:00
|
|
|
c->master_mfact_per = mfact;
|
|
|
|
|
} else {
|
|
|
|
|
w = (m->w.width - mx - cur_gapih - cur_gapih * ie * (r - 1)) /
|
|
|
|
|
r;
|
|
|
|
|
c->master_inner_per = w / (m->w.width - mx - cur_gapih -
|
|
|
|
|
cur_gapih * ie * (r - 1));
|
|
|
|
|
c->master_mfact_per = mfact;
|
|
|
|
|
}
|
2025-06-28 12:35:58 +08:00
|
|
|
resize(c,
|
2025-10-09 13:09:40 +08:00
|
|
|
(struct wlr_box){.x = m->w.x + mx,
|
|
|
|
|
.y = m->w.y + cur_gapov,
|
|
|
|
|
.width = w,
|
|
|
|
|
.height = mh - cur_gapiv * ie},
|
2025-06-28 12:35:58 +08:00
|
|
|
0);
|
2025-10-09 13:09:40 +08:00
|
|
|
mx += c->geom.width + cur_gapih * ie;
|
|
|
|
|
} else {
|
|
|
|
|
r = n - i;
|
2025-12-11 15:44:49 +08:00
|
|
|
if (c->stack_inner_per > 0.0f) {
|
|
|
|
|
w = slave_surplus_width * c->stack_inner_per /
|
2025-12-09 20:35:21 +08:00
|
|
|
slave_surplus_ratio;
|
|
|
|
|
slave_surplus_width = slave_surplus_width - w;
|
2025-12-11 15:44:49 +08:00
|
|
|
slave_surplus_ratio = slave_surplus_ratio - c->stack_inner_per;
|
2025-10-09 13:09:40 +08:00
|
|
|
c->master_mfact_per = mfact;
|
|
|
|
|
} else {
|
|
|
|
|
w = (m->w.width - tx - cur_gapih - cur_gapih * ie * (r - 1)) /
|
|
|
|
|
r;
|
2025-12-11 15:44:49 +08:00
|
|
|
c->stack_inner_per = w / (m->w.width - tx - cur_gapih -
|
|
|
|
|
cur_gapih * ie * (r - 1));
|
2025-10-09 13:09:40 +08:00
|
|
|
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);
|
|
|
|
|
tx += c->geom.width + cur_gapih * ie;
|
2025-06-28 12:35:58 +08:00
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-15 07:24:40 +08:00
|
|
|
void vertical_deck(Monitor *m) {
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t mh, mx;
|
2026-01-03 09:47:49 +08:00
|
|
|
int32_t i, n = 0;
|
2025-10-15 07:24:40 +08:00
|
|
|
Client *c = NULL;
|
|
|
|
|
Client *fc = NULL;
|
|
|
|
|
float mfact;
|
2026-01-27 14:45:28 +08:00
|
|
|
uint32_t nmasters = m->pertag->nmasters[m->pertag->curtag];
|
2025-10-15 07:24:40 +08:00
|
|
|
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
|
|
|
|
|
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
|
|
|
|
|
int32_t cur_gappov = enablegaps ? m->gappov : 0;
|
2025-10-15 07:24:40 +08:00
|
|
|
|
2026-03-12 06:49:58 -07:00
|
|
|
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;
|
2025-10-15 07:24:40 +08:00
|
|
|
|
|
|
|
|
n = m->visible_tiling_clients;
|
|
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(fc, &clients, link) {
|
|
|
|
|
|
|
|
|
|
if (VISIBLEON(fc, m) && ISTILED(fc))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate master width using mfact from pertag
|
|
|
|
|
mfact = fc->master_mfact_per > 0.0f ? fc->master_mfact_per
|
|
|
|
|
: m->pertag->mfacts[m->pertag->curtag];
|
|
|
|
|
|
2026-01-27 14:45:28 +08:00
|
|
|
if (n > nmasters)
|
|
|
|
|
mh = nmasters ? round((m->w.height - 2 * cur_gappov) * mfact) : 0;
|
2025-10-15 07:24:40 +08:00
|
|
|
else
|
|
|
|
|
mh = m->w.height - 2 * cur_gappov;
|
|
|
|
|
|
|
|
|
|
i = mx = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (!VISIBLEON(c, m) || !ISTILED(c))
|
|
|
|
|
continue;
|
2026-01-27 14:45:28 +08:00
|
|
|
if (i < nmasters) {
|
2025-10-15 07:24:40 +08:00
|
|
|
resize(
|
|
|
|
|
c,
|
|
|
|
|
(struct wlr_box){.x = m->w.x + cur_gappoh + mx,
|
|
|
|
|
.y = m->w.y + cur_gappov,
|
|
|
|
|
.width = (m->w.width - 2 * cur_gappoh - mx) /
|
2026-01-27 14:45:28 +08:00
|
|
|
(MIN(n, nmasters) - i),
|
2025-10-15 07:24:40 +08:00
|
|
|
.height = mh},
|
|
|
|
|
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);
|
|
|
|
|
if (c == focustop(m))
|
|
|
|
|
wlr_scene_node_raise_to_top(&c->scene->node);
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-11 16:27:54 +08:00
|
|
|
void vertical_grid(Monitor *m) {
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t i, n;
|
2026-05-16 17:32:39 +08:00
|
|
|
int32_t cw, ch;
|
2026-01-03 10:38:42 +08:00
|
|
|
int32_t rows, cols, overrows;
|
2025-10-11 16:27:54 +08:00
|
|
|
Client *c = NULL;
|
2026-01-03 09:47:49 +08:00
|
|
|
int32_t target_gappo =
|
2026-03-12 06:49:58 -07:00
|
|
|
enablegaps ? m->isoverview ? config.overviewgappo : config.gappov : 0;
|
2026-01-03 09:47:49 +08:00
|
|
|
int32_t target_gappi =
|
2026-03-12 06:49:58 -07:00
|
|
|
enablegaps ? m->isoverview ? config.overviewgappi : config.gappiv : 0;
|
2025-10-11 18:25:08 +08:00
|
|
|
float single_width_ratio = m->isoverview ? 0.7 : 0.9;
|
|
|
|
|
float single_height_ratio = m->isoverview ? 0.8 : 0.9;
|
2025-10-11 16:27:54 +08:00
|
|
|
|
|
|
|
|
n = m->isoverview ? m->visible_clients : m->visible_tiling_clients;
|
2026-05-16 17:32:39 +08:00
|
|
|
if (n == 0)
|
2025-10-11 16:27:54 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (n == 1) {
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (c->mon != m)
|
|
|
|
|
continue;
|
|
|
|
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
2025-11-08 12:41:38 +08:00
|
|
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
2025-10-11 18:25:08 +08:00
|
|
|
ch = (m->w.height - 2 * target_gappo) * single_height_ratio;
|
|
|
|
|
cw = (m->w.width - 2 * target_gappo) * single_width_ratio;
|
2025-10-11 16:27:54 +08:00
|
|
|
c->geom.x = m->w.x + (m->w.width - cw) / 2;
|
|
|
|
|
c->geom.y = m->w.y + (m->w.height - ch) / 2;
|
2025-10-15 16:23:46 +08:00
|
|
|
c->geom.width = cw;
|
|
|
|
|
c->geom.height = ch;
|
2025-10-11 16:27:54 +08:00
|
|
|
resize(c, c->geom, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (n == 2) {
|
2026-05-16 17:32:39 +08:00
|
|
|
float row_pers[2] = {1.0f, 1.0f};
|
|
|
|
|
// 先提取这两个窗口现有的行比例
|
2025-10-11 16:27:54 +08:00
|
|
|
i = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (c->mon != m)
|
|
|
|
|
continue;
|
|
|
|
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
2025-11-08 12:41:38 +08:00
|
|
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
2026-05-16 17:32:39 +08:00
|
|
|
if (i < 2)
|
|
|
|
|
row_pers[i] =
|
|
|
|
|
(c->grid_row_per > 0.0f) ? c->grid_row_per : 1.0f;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float sum_row = row_pers[0] + row_pers[1];
|
|
|
|
|
float avail_h = m->w.height - 2 * target_gappo - target_gappi;
|
|
|
|
|
cw = (m->w.width - 2 * target_gappo) * 0.65; // 依然保持 0.65 的美观宽度
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (c->mon != m)
|
|
|
|
|
continue;
|
|
|
|
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
|
|
|
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
|
|
|
|
c->grid_col_idx = 0;
|
|
|
|
|
c->grid_row_idx = i;
|
|
|
|
|
c->grid_col_per = 1.0f;
|
|
|
|
|
c->grid_row_per = row_pers[i];
|
|
|
|
|
|
|
|
|
|
// 根据分配的权重动态计算当前窗口的高度
|
|
|
|
|
ch = avail_h * (row_pers[i] / sum_row);
|
|
|
|
|
|
|
|
|
|
c->geom.x = m->w.x + (m->w.width - cw) / 2 + target_gappo;
|
2025-10-11 16:27:54 +08:00
|
|
|
if (i == 0) {
|
2025-10-11 18:25:08 +08:00
|
|
|
c->geom.y = m->w.y + target_gappo;
|
2025-10-11 16:27:54 +08:00
|
|
|
} else if (i == 1) {
|
2026-05-16 17:32:39 +08:00
|
|
|
// 第二个窗口的 Y 坐标紧跟第一个窗口下面
|
|
|
|
|
float ch0 = avail_h * (row_pers[0] / sum_row);
|
|
|
|
|
c->geom.y = m->w.y + target_gappo + ch0 + target_gappi;
|
2025-10-11 16:27:54 +08:00
|
|
|
}
|
2026-05-16 17:32:39 +08:00
|
|
|
c->geom.width = cw;
|
|
|
|
|
c->geom.height = ch;
|
|
|
|
|
resize(c, c->geom, 0);
|
2025-10-11 16:27:54 +08:00
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (rows = 0; rows <= n / 2; rows++) {
|
2026-05-16 17:32:39 +08:00
|
|
|
if (rows * rows >= n)
|
2025-10-11 16:27:54 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
|
|
|
|
|
overrows = n % rows;
|
2026-05-16 17:32:39 +08:00
|
|
|
|
|
|
|
|
float col_pers[cols];
|
|
|
|
|
float row_pers[rows];
|
|
|
|
|
for (i = 0; i < cols; i++)
|
|
|
|
|
col_pers[i] = 1.0f;
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
|
row_pers[i] = 1.0f;
|
2025-10-11 16:27:54 +08:00
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (c->mon != m)
|
|
|
|
|
continue;
|
|
|
|
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
2025-11-08 12:41:38 +08:00
|
|
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
2026-05-16 17:32:39 +08:00
|
|
|
int32_t c_idx = i / rows;
|
|
|
|
|
int32_t r_idx = i % rows;
|
|
|
|
|
if (r_idx == 0)
|
|
|
|
|
col_pers[c_idx] =
|
|
|
|
|
(c->grid_col_per > 0.0f) ? c->grid_col_per : 1.0f;
|
|
|
|
|
if (c_idx == 0)
|
|
|
|
|
row_pers[r_idx] =
|
|
|
|
|
(c->grid_row_per > 0.0f) ? c->grid_row_per : 1.0f;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float sum_col = 0.0f, sum_row = 0.0f;
|
|
|
|
|
for (i = 0; i < cols; i++)
|
|
|
|
|
sum_col += col_pers[i];
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
|
sum_row += row_pers[i];
|
|
|
|
|
|
|
|
|
|
float avail_w = m->w.width - 2 * target_gappo - (cols - 1) * target_gappi;
|
|
|
|
|
float avail_h = m->w.height - 2 * target_gappo - (rows - 1) * target_gappi;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (c->mon != m)
|
|
|
|
|
continue;
|
|
|
|
|
if (VISIBLEON(c, m) && !c->isunglobal &&
|
|
|
|
|
((m->isoverview && !client_is_x11_popup(c)) || ISTILED(c))) {
|
|
|
|
|
int32_t c_idx = i / rows;
|
|
|
|
|
int32_t r_idx = i % rows;
|
|
|
|
|
|
|
|
|
|
c->grid_col_per = col_pers[c_idx];
|
|
|
|
|
c->grid_row_per = row_pers[r_idx];
|
|
|
|
|
c->grid_col_idx = c_idx;
|
|
|
|
|
c->grid_row_idx = r_idx;
|
|
|
|
|
|
|
|
|
|
float fl_cy = m->w.y + target_gappo;
|
|
|
|
|
float fl_ch = 0.0f;
|
|
|
|
|
|
2025-10-11 16:27:54 +08:00
|
|
|
if (overrows && i >= n - overrows) {
|
2026-05-16 17:32:39 +08:00
|
|
|
float over_h = 0.0f;
|
|
|
|
|
for (int j = 0; j < overrows; j++)
|
|
|
|
|
over_h += avail_h * (row_pers[j] / sum_row);
|
|
|
|
|
over_h += (overrows - 1) * target_gappi;
|
|
|
|
|
float dy = (m->w.height - over_h) / 2.0f - target_gappo;
|
|
|
|
|
|
|
|
|
|
fl_cy += dy;
|
|
|
|
|
for (int j = 0; j < r_idx; j++)
|
|
|
|
|
fl_cy += avail_h * (row_pers[j] / sum_row) + target_gappi;
|
|
|
|
|
fl_ch = avail_h * (row_pers[r_idx] / sum_row);
|
|
|
|
|
} else {
|
|
|
|
|
for (int j = 0; j < r_idx; j++)
|
|
|
|
|
fl_cy += avail_h * (row_pers[j] / sum_row) + target_gappi;
|
|
|
|
|
fl_ch = (r_idx == rows - 1)
|
|
|
|
|
? (m->w.y + m->w.height - target_gappo - fl_cy)
|
|
|
|
|
: avail_h * (row_pers[r_idx] / sum_row);
|
2025-10-11 16:27:54 +08:00
|
|
|
}
|
2026-05-16 17:32:39 +08:00
|
|
|
|
|
|
|
|
float fl_cx = m->w.x + target_gappo;
|
|
|
|
|
for (int j = 0; j < c_idx; j++)
|
|
|
|
|
fl_cx += avail_w * (col_pers[j] / sum_col) + target_gappi;
|
|
|
|
|
float fl_cw = (c_idx == cols - 1)
|
|
|
|
|
? (m->w.x + m->w.width - target_gappo - fl_cx)
|
|
|
|
|
: avail_w * (col_pers[c_idx] / sum_col);
|
|
|
|
|
|
|
|
|
|
c->geom.x = (int32_t)fl_cx;
|
|
|
|
|
c->geom.y = (int32_t)fl_cy;
|
|
|
|
|
c->geom.width = (int32_t)fl_cw;
|
|
|
|
|
c->geom.height = (int32_t)fl_ch;
|
2025-10-11 16:27:54 +08:00
|
|
|
resize(c, c->geom, 0);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-16 08:23:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vertical_fair(Monitor *m) {
|
|
|
|
|
int32_t i, n = 0;
|
|
|
|
|
Client *c = NULL;
|
|
|
|
|
|
|
|
|
|
n = m->visible_tiling_clients;
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int32_t cur_gappiv = enablegaps ? m->gappiv : 0;
|
|
|
|
|
int32_t cur_gappih = enablegaps ? m->gappih : 0;
|
|
|
|
|
int32_t cur_gappov = enablegaps ? m->gappov : 0;
|
|
|
|
|
int32_t cur_gappoh = enablegaps ? m->gappoh : 0;
|
|
|
|
|
|
|
|
|
|
cur_gappiv = config.smartgaps && n == 1 ? 0 : cur_gappiv;
|
|
|
|
|
cur_gappih = config.smartgaps && n == 1 ? 0 : cur_gappih;
|
|
|
|
|
cur_gappov = config.smartgaps && n == 1 ? 0 : cur_gappov;
|
|
|
|
|
cur_gappoh = config.smartgaps && n == 1 ? 0 : cur_gappoh;
|
|
|
|
|
|
|
|
|
|
int32_t rows;
|
|
|
|
|
for (rows = 0; rows <= n; rows++) {
|
|
|
|
|
if (rows * rows >= n)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-16 17:32:39 +08:00
|
|
|
int32_t base_cols = n / rows;
|
|
|
|
|
int32_t remainder = n % rows;
|
2026-05-16 16:31:16 +08:00
|
|
|
int32_t first_group_rows = rows - remainder;
|
|
|
|
|
int32_t first_group_count = first_group_rows * base_cols;
|
2026-05-16 17:32:39 +08:00
|
|
|
int32_t max_cols = base_cols + (remainder > 0 ? 1 : 0);
|
2026-05-16 08:23:48 +08:00
|
|
|
|
2026-05-16 17:32:39 +08:00
|
|
|
float row_pers[rows];
|
|
|
|
|
float col_pers[max_cols];
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
|
row_pers[i] = 1.0f;
|
|
|
|
|
for (i = 0; i < max_cols; i++)
|
|
|
|
|
col_pers[i] = 1.0f;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (!VISIBLEON(c, m) || !ISTILED(c))
|
|
|
|
|
continue;
|
|
|
|
|
int32_t row_idx, col_idx;
|
|
|
|
|
if (i < first_group_count) {
|
|
|
|
|
row_idx = i / base_cols;
|
|
|
|
|
col_idx = i % base_cols;
|
|
|
|
|
} else {
|
|
|
|
|
int32_t offset = i - first_group_count;
|
|
|
|
|
row_idx = first_group_rows + (offset / (base_cols + 1));
|
|
|
|
|
col_idx = offset % (base_cols + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (col_idx == 0)
|
|
|
|
|
row_pers[row_idx] =
|
|
|
|
|
(c->grid_row_per > 0.0f) ? c->grid_row_per : 1.0f;
|
|
|
|
|
if (row_idx == 0)
|
|
|
|
|
col_pers[col_idx] =
|
|
|
|
|
(c->grid_col_per > 0.0f) ? c->grid_col_per : 1.0f;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float sum_row = 0.0f;
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
|
sum_row += row_pers[i];
|
|
|
|
|
float avail_h = m->w.height - 2 * cur_gappov - (rows - 1) * cur_gappiv;
|
2026-05-16 08:23:48 +08:00
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (!VISIBLEON(c, m) || !ISTILED(c))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
int32_t row_idx, col_idx, cols_in_this_row;
|
2026-05-16 16:31:16 +08:00
|
|
|
if (i < first_group_count) {
|
|
|
|
|
row_idx = i / base_cols;
|
|
|
|
|
col_idx = i % base_cols;
|
2026-05-16 08:23:48 +08:00
|
|
|
cols_in_this_row = base_cols;
|
2026-05-16 16:31:16 +08:00
|
|
|
} else {
|
|
|
|
|
int32_t offset = i - first_group_count;
|
|
|
|
|
row_idx = first_group_rows + (offset / (base_cols + 1));
|
|
|
|
|
col_idx = offset % (base_cols + 1);
|
|
|
|
|
cols_in_this_row = base_cols + 1;
|
2026-05-16 08:23:48 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-16 17:32:39 +08:00
|
|
|
c->grid_row_per = row_pers[row_idx];
|
|
|
|
|
c->grid_col_per = col_pers[col_idx];
|
|
|
|
|
c->grid_row_idx = row_idx;
|
|
|
|
|
c->grid_col_idx = col_idx;
|
2026-05-16 08:23:48 +08:00
|
|
|
|
2026-05-16 17:32:39 +08:00
|
|
|
float fl_cy = m->w.y + cur_gappov;
|
|
|
|
|
for (int j = 0; j < row_idx; j++)
|
|
|
|
|
fl_cy += avail_h * (row_pers[j] / sum_row) + cur_gappiv;
|
|
|
|
|
float fl_ch = (row_idx == rows - 1)
|
|
|
|
|
? (m->w.y + m->w.height - cur_gappov - fl_cy)
|
|
|
|
|
: avail_h * (row_pers[row_idx] / sum_row);
|
2026-05-16 08:23:48 +08:00
|
|
|
|
2026-05-16 17:32:39 +08:00
|
|
|
float sum_col_this_row = 0.0f;
|
|
|
|
|
for (int j = 0; j < cols_in_this_row; j++)
|
|
|
|
|
sum_col_this_row += col_pers[j];
|
|
|
|
|
|
|
|
|
|
float avail_w =
|
|
|
|
|
m->w.width - 2 * cur_gappoh - (cols_in_this_row - 1) * cur_gappih;
|
|
|
|
|
float fl_cx = m->w.x + cur_gappoh;
|
|
|
|
|
for (int j = 0; j < col_idx; j++)
|
|
|
|
|
fl_cx += avail_w * (col_pers[j] / sum_col_this_row) + cur_gappih;
|
|
|
|
|
float fl_cw = (col_idx == cols_in_this_row - 1)
|
|
|
|
|
? (m->w.x + m->w.width - cur_gappoh - fl_cx)
|
|
|
|
|
: avail_w * (col_pers[col_idx] / sum_col_this_row);
|
|
|
|
|
|
|
|
|
|
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},
|
2026-05-16 08:23:48 +08:00
|
|
|
0);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2025-10-11 16:27:54 +08:00
|
|
|
}
|