diff --git a/sway/commands/resize.c b/sway/commands/resize.c index f59e2aeb20..79a8719ab3 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -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; } @@ -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; } @@ -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; }