mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
Layout containers with fullscreen child correctly
When a container that includes a child that's fullscreen gets re-arranged also adjust the saved width/height of the fullscreen window so that on fullscreen exit the layout is correct. Fixes #3547
This commit is contained in:
parent
e1a6c5ee06
commit
89ce6a80f1
3 changed files with 29 additions and 8 deletions
|
|
@ -87,6 +87,7 @@ struct sway_container {
|
||||||
double width, height;
|
double width, height;
|
||||||
double saved_x, saved_y;
|
double saved_x, saved_y;
|
||||||
double saved_width, saved_height;
|
double saved_width, saved_height;
|
||||||
|
bool saved_dims;
|
||||||
|
|
||||||
// These are in layout coordinates.
|
// These are in layout coordinates.
|
||||||
double content_x, content_y;
|
double content_x, content_y;
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,12 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container_remove_gaps(child);
|
container_remove_gaps(child);
|
||||||
|
if (child->saved_dims) {
|
||||||
|
total_width += child->saved_width;
|
||||||
|
} else {
|
||||||
total_width += child->width;
|
total_width += child->width;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
double scale = parent->width / total_width;
|
double scale = parent->width / total_width;
|
||||||
|
|
||||||
// Resize windows
|
// Resize windows
|
||||||
|
|
@ -51,12 +55,16 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
|
||||||
child->x = child_x;
|
child->x = child_x;
|
||||||
child->y = parent->y;
|
child->y = parent->y;
|
||||||
child->width = floor(child->width * scale);
|
child->width = floor(child->width * scale);
|
||||||
|
child->saved_width = floor(child->saved_width * scale);
|
||||||
child->height = parent->height;
|
child->height = parent->height;
|
||||||
|
if (child->saved_dims) {
|
||||||
|
child_x += child->saved_width;
|
||||||
|
} else {
|
||||||
child_x += child->width;
|
child_x += child->width;
|
||||||
|
}
|
||||||
// Make last child use remaining width of parent
|
// Make last child use remaining width of parent
|
||||||
if (i == children->length - 1) {
|
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);
|
container_add_gaps(child);
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +96,12 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container_remove_gaps(child);
|
container_remove_gaps(child);
|
||||||
|
if (child->saved_dims) {
|
||||||
|
total_height += child->saved_height;
|
||||||
|
} else {
|
||||||
total_height += child->height;
|
total_height += child->height;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
double scale = parent->height / total_height;
|
double scale = parent->height / total_height;
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
|
|
@ -101,11 +113,15 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
|
||||||
child->y = child_y;
|
child->y = child_y;
|
||||||
child->width = parent->width;
|
child->width = parent->width;
|
||||||
child->height = floor(child->height * scale);
|
child->height = floor(child->height * scale);
|
||||||
|
child->saved_height = floor(child->saved_height * scale);
|
||||||
|
if (child->saved_dims) {
|
||||||
|
child_y += child->saved_height;
|
||||||
|
} else {
|
||||||
child_y += child->height;
|
child_y += child->height;
|
||||||
|
}
|
||||||
// Make last child use remaining height of parent
|
// Make last child use remaining height of parent
|
||||||
if (i == children->length - 1) {
|
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);
|
container_add_gaps(child);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
c->layout = L_NONE;
|
c->layout = L_NONE;
|
||||||
c->view = view;
|
c->view = view;
|
||||||
c->alpha = 1.0f;
|
c->alpha = 1.0f;
|
||||||
|
c->saved_dims = false;
|
||||||
|
|
||||||
if (!view) {
|
if (!view) {
|
||||||
c->children = create_list();
|
c->children = create_list();
|
||||||
|
|
@ -964,6 +965,7 @@ static void container_fullscreen_workspace(struct sway_container *con) {
|
||||||
con->saved_y = con->y;
|
con->saved_y = con->y;
|
||||||
con->saved_width = con->width;
|
con->saved_width = con->width;
|
||||||
con->saved_height = con->height;
|
con->saved_height = con->height;
|
||||||
|
con->saved_dims = true;
|
||||||
|
|
||||||
if (con->workspace) {
|
if (con->workspace) {
|
||||||
con->workspace->fullscreen = con;
|
con->workspace->fullscreen = con;
|
||||||
|
|
@ -996,6 +998,7 @@ static void container_fullscreen_global(struct sway_container *con) {
|
||||||
con->saved_y = con->y;
|
con->saved_y = con->y;
|
||||||
con->saved_width = con->width;
|
con->saved_width = con->width;
|
||||||
con->saved_height = con->height;
|
con->saved_height = con->height;
|
||||||
|
con->saved_dims = true;
|
||||||
|
|
||||||
struct sway_seat *seat;
|
struct sway_seat *seat;
|
||||||
wl_list_for_each(seat, &server.input->seats, link) {
|
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->width = con->saved_width;
|
||||||
con->height = con->saved_height;
|
con->height = con->saved_height;
|
||||||
|
con->saved_dims = false;
|
||||||
|
|
||||||
if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
|
if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
|
||||||
if (con->workspace) {
|
if (con->workspace) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue