diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 8448d7059..db3e24944 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -87,6 +87,7 @@ struct sway_container { double width, height; double saved_x, saved_y; double saved_width, saved_height; + bool saved_dims; // These are in layout coordinates. double content_x, content_y; diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index fc5d49ed0..bb2166279 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c @@ -39,7 +39,11 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) { } } container_remove_gaps(child); - total_width += child->width; + if (child->saved_dims) { + total_width += child->saved_width; + } else { + total_width += child->width; + } } double scale = parent->width / total_width; @@ -51,12 +55,16 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) { child->x = child_x; child->y = parent->y; child->width = floor(child->width * scale); + child->saved_width = floor(child->saved_width * scale); child->height = parent->height; - child_x += child->width; - + if (child->saved_dims) { + child_x += child->saved_width; + } else { + child_x += child->width; + } // Make last child use remaining width of parent if (i == children->length - 1) { - child->width = parent->x + parent->width - child->x; + child->width = child->saved_width = parent->x + parent->width - child->x; } container_add_gaps(child); } @@ -88,7 +96,11 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { } } container_remove_gaps(child); - total_height += child->height; + if (child->saved_dims) { + total_height += child->saved_height; + } else { + total_height += child->height; + } } double scale = parent->height / total_height; @@ -101,11 +113,15 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { child->y = child_y; child->width = parent->width; child->height = floor(child->height * scale); - child_y += child->height; - + child->saved_height = floor(child->saved_height * scale); + if (child->saved_dims) { + child_y += child->saved_height; + } else { + child_y += child->height; + } // Make last child use remaining height of parent if (i == children->length - 1) { - child->height = parent->y + parent->height - child->y; + child->height = child->saved_height = parent->y + parent->height - child->y; } container_add_gaps(child); } diff --git a/sway/tree/container.c b/sway/tree/container.c index 89a471513..591bf9b1a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -35,6 +35,7 @@ struct sway_container *container_create(struct sway_view *view) { c->layout = L_NONE; c->view = view; c->alpha = 1.0f; + c->saved_dims = false; if (!view) { c->children = create_list(); @@ -964,6 +965,7 @@ static void container_fullscreen_workspace(struct sway_container *con) { con->saved_y = con->y; con->saved_width = con->width; con->saved_height = con->height; + con->saved_dims = true; if (con->workspace) { con->workspace->fullscreen = con; @@ -996,6 +998,7 @@ static void container_fullscreen_global(struct sway_container *con) { con->saved_y = con->y; con->saved_width = con->width; con->saved_height = con->height; + con->saved_dims = true; struct sway_seat *seat; wl_list_for_each(seat, &server.input->seats, link) { @@ -1025,6 +1028,7 @@ void container_fullscreen_disable(struct sway_container *con) { } con->width = con->saved_width; con->height = con->saved_height; + con->saved_dims = false; if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { if (con->workspace) {