From e3a3917d3afb66fc8ba3eebb7aed603d3b7ce844 Mon Sep 17 00:00:00 2001 From: Pedro CĂ´rte-Real Date: Fri, 28 Jun 2019 22:21:20 +0100 Subject: Layout tiled using a width/height fraction Instead of using container->width/height as both the input and output of the layout calculation have container->width_fraction/height_fraction as the share of the parent this container occupies and calculate the layout based on that. That way the container arrangement can always be recalculated even if width/height have been altered by things like fullscreen. To do this several parts are reworked: - The vertical and horizontal arrangement code is ajusted to work with fractions instead of directly with width/height - The resize code is then changed to manipulate the fractions when working on tiled containers. - Finally the places that manipulated width/height are adjusted to match. The adjusted parts are container split, swap, and the input seat code. It's possible that some parts of the code are now adjusting width and height only for those to be immediately recalculated. That's harmless and since non-tiled containers are still sized with width/height directly it may avoid breaking other corner cases. Fixes #3547 Fixes #4297 --- sway/tree/container.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sway/tree/container.c') diff --git a/sway/tree/container.c b/sway/tree/container.c index 9046ae27..068dbb88 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -789,6 +789,8 @@ void container_set_floating(struct sway_container *container, bool enable) { container->border = container->saved_border; } } + container->width_fraction = 0; + container->height_fraction = 0; } container_end_mouse_operation(container); @@ -1022,9 +1024,9 @@ void container_fullscreen_disable(struct sway_container *con) { if (container_is_floating(con)) { con->x = con->saved_x; con->y = con->saved_y; + con->width = con->saved_width; + con->height = con->saved_height; } - con->width = con->saved_width; - con->height = con->saved_height; if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { if (con->workspace) { @@ -1415,6 +1417,8 @@ struct sway_container *container_split(struct sway_container *child, struct sway_container *cont = container_create(NULL); cont->width = child->width; cont->height = child->height; + cont->width_fraction = child->width_fraction; + cont->height_fraction = child->height_fraction; cont->x = child->x; cont->y = child->y; cont->current_gaps = child->current_gaps; -- cgit v1.2.3-54-g00ecf