Skip to content

Commit

Permalink
fix crash when resizing tiled scratchpad windows
Browse files Browse the repository at this point in the history
Splitting and then hiding a scratchpad container results in
a segfault.

Related: swaywm#6693
  • Loading branch information
bretello committed Jul 17, 2023
1 parent 9107907 commit a90a177
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sway/commands/resize.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ struct sway_container *container_find_resize_parent(struct sway_container *con,

while (con) {
list_t *siblings = container_get_siblings(con);
int index = container_sibling_index(con);
if (container_parent_layout(con) == parallel_layout &&
if (siblings){
int index = container_sibling_index(con);
if (container_parent_layout(con) == parallel_layout &&
siblings->length > 1 && (allow_first || index > 0) &&
(allow_last || index < siblings->length - 1)) {
return con;
return con;
}
}
con = con->pending.parent;
}
Expand Down Expand Up @@ -302,8 +304,11 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
}
if (parent) {
width->amount = parent->pending.width * width->amount / 100;
} else {
} else if (con->pending.workspace) {
width->amount = con->pending.workspace->width * width->amount / 100;
} else {
return cmd_results_new(CMD_FAILURE,
"Cannot resize a tiled container with no parent or workspace");
}
width->unit = MOVEMENT_UNIT_PX;
}
Expand All @@ -323,8 +328,11 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
}
if (parent) {
height->amount = parent->pending.height * height->amount / 100;
} else {
} else if (con->pending.workspace) {
height->amount = con->pending.workspace->height * height->amount / 100;
} else {
return cmd_results_new(CMD_FAILURE,
"Cannot resize a tiled container with no parent or workspace");
}
height->unit = MOVEMENT_UNIT_PX;
}
Expand Down

0 comments on commit a90a177

Please sign in to comment.