add variable main stack size

This commit is contained in:
2026-04-04 16:59:31 +07:00
parent b92d1c1b02
commit 7601b86450
2 changed files with 33 additions and 10 deletions
+31 -9
View File
@@ -12,7 +12,6 @@ void layout_arrange(struct absinthe_output *output)
toplevels_count++;
}
if (toplevels_count < 1)
return;
@@ -34,24 +33,47 @@ void layout_arrange(struct absinthe_output *output)
}
int32_t layout_gap = ABSINTHE_LAYOUT_GAP;
int32_t main_toplevel_width = ABSINTHE_MAIN_TOPLEVEL_WIDTH * (output->geometry.width - 2 * output_gap);
int32_t width, height;
width = output->geometry.width - main_toplevel_width - borders_width - layout_gap - 2 * output_gap;
int32_t main_stack_width = (toplevels_count <= ABSINTHE_MAIN_STACK_SIZE)
? output->geometry.width - borders_width - 2 * output_gap
: ABSINTHE_MAIN_STACK_WIDTH * (output->geometry.width - 2 * output_gap);
int32_t width = output->geometry.width - main_stack_width - borders_width - layout_gap - 2 * output_gap;
int32_t height;
int32_t dy = output_gap;
size_t i = 0;
if (toplevels_count <= ABSINTHE_MAIN_STACK_SIZE) {
wl_list_for_each(toplevel, &output->server->toplevels, link) {
if (toplevel->output != output)
continue;
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_stack_width, height);
toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + dy;
dy += height + borders_width + layout_gap;
i++;
}
return;
}
wl_list_for_each(toplevel, &output->server->toplevels, link) {
if (toplevel->output != output)
continue;
if (i == 0) {
height = output->geometry.height - borders_width - 2 * output_gap;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_toplevel_width, height);
if (i < ABSINTHE_MAIN_STACK_SIZE) {
height = (output->geometry.height - dy - output_gap) / (ABSINTHE_MAIN_STACK_SIZE - i) - borders_width;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, main_stack_width, height);
toplevel->geometry.x = output->geometry.x + output_gap;
toplevel->geometry.y = output->geometry.y + output_gap;
toplevel->geometry.y = output->geometry.y + dy;
dy += height + borders_width + layout_gap;
} else {
if (i == ABSINTHE_MAIN_STACK_SIZE)
dy = output_gap;
height = (output->geometry.height - dy - output_gap) / (toplevels_count - i) - borders_width;
wlr_xdg_toplevel_set_size(toplevel->toplevel.xdg, width, height);
toplevel->geometry.x = output->geometry.x + main_toplevel_width + layout_gap + output_gap;
toplevel->geometry.x = output->geometry.x + main_stack_width + layout_gap + output_gap;
toplevel->geometry.y = output->geometry.y + dy;
dy += height + borders_width + layout_gap;
}