When unfloating, return container to previously focused tiled container

This introduces seat_get_focus_inactive_tiling and updates
`focus mode_toggle` to use it instead, because the previous method
wasn't guaranteed to return a tiling view.
This commit is contained in:
Ryan Dwyer 2018-07-26 22:58:42 +10:00
parent 936168e740
commit da2a87f6c7
4 changed files with 32 additions and 13 deletions

View file

@ -35,14 +35,16 @@ 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);
struct sway_container *new_focus = ws;
struct sway_container *new_focus = NULL;
if (floating) {
new_focus = ws->sway_workspace->floating;
if (new_focus->children->length == 0) {
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
new_focus = seat_get_focus_inactive(seat, ws->sway_workspace->floating);
} else {
new_focus = seat_get_focus_inactive_tiling(seat, ws);
}
seat_set_focus(seat, seat_get_active_child(seat, new_focus));
if (!new_focus) {
new_focus = ws;
}
seat_set_focus(seat, new_focus);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}