diff --git a/src/layout/horizontal.h b/src/layout/horizontal.h index 0dc77d4..050a8b8 100644 --- a/src/layout/horizontal.h +++ b/src/layout/horizontal.h @@ -224,17 +224,39 @@ void arrange_stack(Client *scroller_stack_head, struct wlr_box geometry, if (stack_size == 0) return; - int32_t client_height = - (geometry.height - (stack_size - 1) * gappiv) / stack_size; - int32_t current_y = geometry.y; + float total_proportion = 0.0f; + iter = scroller_stack_head; + while (iter) { + if(iter->stack_proportion <= 0.0f || iter->stack_proportion >= 1.0f) { + iter->stack_proportion = stack_size == 1 ? 1.0f : 1.0f/(stack_size - 1); + } + total_proportion += iter->stack_proportion; + iter = iter->next_in_stack; + } iter = scroller_stack_head; while (iter) { + iter->stack_proportion = iter->stack_proportion / total_proportion; + iter = iter->next_in_stack; + } + + int32_t client_height; + int32_t current_y = geometry.y; + int32_t remain_client_height = geometry.height - (stack_size - 1) * gappiv; + float remain_proportion = 1.0f; + + iter = scroller_stack_head; + while (iter) { + + client_height = remain_client_height * (iter->stack_proportion / remain_proportion); + struct wlr_box client_geom = {.x = geometry.x, .y = current_y, .width = geometry.width, .height = client_height}; resize(iter, client_geom, 0); + remain_proportion -= iter->stack_proportion; + remain_client_height -= client_height; current_y += client_height + gappiv; iter = iter->next_in_stack; } diff --git a/src/layout/vertical.h b/src/layout/vertical.h index f04866b..26ca4a9 100644 --- a/src/layout/vertical.h +++ b/src/layout/vertical.h @@ -199,8 +199,8 @@ void vertical_scroll_adjust_fullandmax(Client *c, struct wlr_box *target_geom) { target_geom->x = m->w.x + (m->w.width - target_geom->width) / 2; } -void arrange_stack_vertical(Client *scroller_stack_head, - struct wlr_box geometry, int32_t gappih) { +void arrange_stack_vertical(Client *scroller_stack_head, struct wlr_box geometry, + int32_t gappih) { int32_t stack_size = 0; Client *iter = scroller_stack_head; while (iter) { @@ -211,17 +211,39 @@ void arrange_stack_vertical(Client *scroller_stack_head, if (stack_size == 0) return; - int32_t client_width = - (geometry.width - (stack_size - 1) * gappih) / stack_size; - int32_t current_x = geometry.x; + float total_proportion = 0.0f; + iter = scroller_stack_head; + while (iter) { + if(iter->stack_proportion <= 0.0f || iter->stack_proportion >= 1.0f) { + iter->stack_proportion = stack_size == 1 ? 1.0f : 1.0f/(stack_size - 1); + } + total_proportion += iter->stack_proportion; + iter = iter->next_in_stack; + } iter = scroller_stack_head; while (iter) { + iter->stack_proportion = iter->stack_proportion / total_proportion; + iter = iter->next_in_stack; + } + + int32_t client_width; + int32_t current_x = geometry.x; + int32_t remain_client_width = geometry.width - (stack_size - 1) * gappih; + float remain_proportion = 1.0f; + + iter = scroller_stack_head; + while (iter) { + + client_width = remain_client_width * (iter->stack_proportion / remain_proportion); + struct wlr_box client_geom = {.y = geometry.y, .x = current_x, .height = geometry.height, .width = client_width}; resize(iter, client_geom, 0); + remain_proportion -= iter->stack_proportion; + remain_client_width -= client_width; current_x += client_width + gappih; iter = iter->next_in_stack; } diff --git a/src/mango.c b/src/mango.c index 9b43a14..6d2f44e 100644 --- a/src/mango.c +++ b/src/mango.c @@ -375,6 +375,7 @@ struct Client { bool is_pending_open_animation; bool is_restoring_from_ov; float scroller_proportion; + float stack_proportion; bool need_output_flush; struct dwl_animation animation; struct dwl_opacity_animation opacity_animation;