diff options
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r-- | sway/commands/focus.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 9cd8bfae..76d3f1dc 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -35,14 +35,25 @@ static struct cmd_results *focus_mode(struct sway_container *con, | |||
35 | struct sway_seat *seat, bool floating) { | 35 | struct sway_seat *seat, bool floating) { |
36 | struct sway_container *ws = con->type == C_WORKSPACE ? | 36 | struct sway_container *ws = con->type == C_WORKSPACE ? |
37 | con : container_parent(con, C_WORKSPACE); | 37 | con : container_parent(con, C_WORKSPACE); |
38 | struct sway_container *new_focus = ws; | 38 | |
39 | if (floating) { | 39 | // If the container is in a floating split container, |
40 | new_focus = ws->sway_workspace->floating; | 40 | // operate on the split container instead of the child. |
41 | if (new_focus->children->length == 0) { | 41 | if (container_is_floating_or_child(con)) { |
42 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 42 | while (con->parent->layout != L_FLOATING) { |
43 | con = con->parent; | ||
43 | } | 44 | } |
44 | } | 45 | } |
45 | seat_set_focus(seat, seat_get_active_child(seat, new_focus)); | 46 | |
47 | struct sway_container *new_focus = NULL; | ||
48 | if (floating) { | ||
49 | new_focus = seat_get_focus_inactive(seat, ws->sway_workspace->floating); | ||
50 | } else { | ||
51 | new_focus = seat_get_focus_inactive_tiling(seat, ws); | ||
52 | } | ||
53 | if (!new_focus) { | ||
54 | new_focus = ws; | ||
55 | } | ||
56 | seat_set_focus(seat, new_focus); | ||
46 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 57 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
47 | } | 58 | } |
48 | 59 | ||
@@ -97,7 +108,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { | |||
97 | } else if (strcmp(argv[0], "tiling") == 0) { | 108 | } else if (strcmp(argv[0], "tiling") == 0) { |
98 | return focus_mode(con, seat, false); | 109 | return focus_mode(con, seat, false); |
99 | } else if (strcmp(argv[0], "mode_toggle") == 0) { | 110 | } else if (strcmp(argv[0], "mode_toggle") == 0) { |
100 | return focus_mode(con, seat, !container_is_floating(con)); | 111 | return focus_mode(con, seat, !container_is_floating_or_child(con)); |
101 | } | 112 | } |
102 | 113 | ||
103 | if (strcmp(argv[0], "output") == 0) { | 114 | if (strcmp(argv[0], "output") == 0) { |