mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-23 21:37:53 -04:00
opt: make big one as the last open window in fair layout
This commit is contained in:
parent
469249b39e
commit
04a3074fb4
2 changed files with 28 additions and 18 deletions
|
|
@ -704,7 +704,11 @@ void fair(Monitor *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t base_rows = n / cols; // 每列的基础行数
|
int32_t base_rows = n / cols; // 每列的基础行数
|
||||||
int32_t remainder = n % cols; // 多出来的窗口,分配给前 remainder 列
|
int32_t remainder = n % cols; // 多出来的窗口
|
||||||
|
|
||||||
|
// 计算前半部分(大窗口)的列数和总窗口数
|
||||||
|
int32_t first_group_cols = cols - remainder;
|
||||||
|
int32_t first_group_count = first_group_cols * base_rows;
|
||||||
|
|
||||||
// 计算标准列宽
|
// 计算标准列宽
|
||||||
int32_t col_width =
|
int32_t col_width =
|
||||||
|
|
@ -718,15 +722,16 @@ void fair(Monitor *m) {
|
||||||
int32_t col_idx, row_idx, rows_in_this_col;
|
int32_t col_idx, row_idx, rows_in_this_col;
|
||||||
|
|
||||||
// 判断当前窗口属于哪一列、哪一行
|
// 判断当前窗口属于哪一列、哪一行
|
||||||
if (i < remainder * (base_rows + 1)) {
|
// 前半部分列拥有较少的行数(窗口更大),后半部分列承担余数(窗口更小)
|
||||||
col_idx = i / (base_rows + 1);
|
if (i < first_group_count) {
|
||||||
row_idx = i % (base_rows + 1);
|
col_idx = i / base_rows;
|
||||||
rows_in_this_col = base_rows + 1;
|
row_idx = i % base_rows;
|
||||||
} else {
|
|
||||||
int32_t offset = i - remainder * (base_rows + 1);
|
|
||||||
col_idx = remainder + offset / base_rows;
|
|
||||||
row_idx = offset % base_rows;
|
|
||||||
rows_in_this_col = base_rows;
|
rows_in_this_col = base_rows;
|
||||||
|
} else {
|
||||||
|
int32_t offset = i - first_group_count;
|
||||||
|
col_idx = first_group_cols + (offset / (base_rows + 1));
|
||||||
|
row_idx = offset % (base_rows + 1);
|
||||||
|
rows_in_this_col = base_rows + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算 X 坐标和宽度 (最后一列吃掉剩余像素,防止缝隙)
|
// 计算 X 坐标和宽度 (最后一列吃掉剩余像素,防止缝隙)
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,11 @@ void vertical_fair(Monitor *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t base_cols = n / rows; // 每行的基础列数
|
int32_t base_cols = n / rows; // 每行的基础列数
|
||||||
int32_t remainder = n % rows; // 多出来的窗口,分配给前 remainder 行
|
int32_t remainder = n % rows; // 多出来的窗口
|
||||||
|
|
||||||
|
// 计算上半部分(大窗口)的行数和总窗口数
|
||||||
|
int32_t first_group_rows = rows - remainder;
|
||||||
|
int32_t first_group_count = first_group_rows * base_cols;
|
||||||
|
|
||||||
// 计算标准行高
|
// 计算标准行高
|
||||||
int32_t row_height =
|
int32_t row_height =
|
||||||
|
|
@ -325,15 +329,16 @@ void vertical_fair(Monitor *m) {
|
||||||
int32_t row_idx, col_idx, cols_in_this_row;
|
int32_t row_idx, col_idx, cols_in_this_row;
|
||||||
|
|
||||||
// 判断当前窗口属于哪一行、哪一列
|
// 判断当前窗口属于哪一行、哪一列
|
||||||
if (i < remainder * (base_cols + 1)) {
|
// 上半部分行拥有较少的列数(窗口更宽),下半部分行承担余数(窗口更窄)
|
||||||
row_idx = i / (base_cols + 1);
|
if (i < first_group_count) {
|
||||||
col_idx = i % (base_cols + 1);
|
row_idx = i / base_cols;
|
||||||
cols_in_this_row = base_cols + 1;
|
col_idx = i % base_cols;
|
||||||
} else {
|
|
||||||
int32_t offset = i - remainder * (base_cols + 1);
|
|
||||||
row_idx = remainder + offset / base_cols;
|
|
||||||
col_idx = offset % base_cols;
|
|
||||||
cols_in_this_row = base_cols;
|
cols_in_this_row = 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);
|
||||||
|
cols_in_this_row = base_cols + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算 Y 坐标和高度 (最后一行吃掉剩余像素)
|
// 计算 Y 坐标和高度 (最后一行吃掉剩余像素)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue