Fix focus mode_toggle from a child of a floating container

Also fixes a crash when unfloating a window. It needs to add it back to
the tiling tree as a sibling rather than a child, because the reference
container might be a view.
This commit is contained in:
Ryan Dwyer 2018-07-27 09:10:10 +10:00
parent c95847c9e1
commit 538e083f61
2 changed files with 11 additions and 2 deletions

View file

@ -35,6 +35,15 @@ static struct cmd_results *focus_mode(struct sway_container *con,
struct sway_seat *seat, bool floating) {
struct sway_container *ws = con->type == C_WORKSPACE ?
con : container_parent(con, C_WORKSPACE);
// If the container is in a floating split container,
// operate on the split container instead of the child.
if (container_is_floating_or_child(con)) {
while (con->parent->layout != L_FLOATING) {
con = con->parent;
}
}
struct sway_container *new_focus = NULL;
if (floating) {
new_focus = seat_get_focus_inactive(seat, ws->sway_workspace->floating);
@ -99,7 +108,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) {
} else if (strcmp(argv[0], "tiling") == 0) {
return focus_mode(con, seat, false);
} else if (strcmp(argv[0], "mode_toggle") == 0) {
return focus_mode(con, seat, !container_is_floating(con));
return focus_mode(con, seat, !container_is_floating_or_child(con));
}
if (strcmp(argv[0], "output") == 0) {

View file

@ -1033,7 +1033,7 @@ void container_set_floating(struct sway_container *container, bool enable) {
struct sway_container *sibling =
seat_get_focus_inactive_tiling(seat, workspace);
container_remove_child(container);
container_add_child(sibling, container);
container_add_sibling(sibling, container);
container->width = container->parent->width;
container->height = container->parent->height;
if (container->type == C_VIEW) {