aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/focus.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-08-02 23:49:25 +0100
committerGitHub <noreply@github.com>2018-08-02 23:49:25 +0100
commit3a54e2291c017397ceff60511c29fe70d229bc8b (patch)
treed340b7776f945462f5ecffc830ada4d5fbe82f51 /sway/commands/focus.c
parentc35a34262f8da368f65d37f811a2264647e0dae6 (diff)
parente07da5fc5c6ac5c186662b56b08ca71531119de0 (diff)
Merge branch 'master' into wlr-gamma-control
Diffstat (limited to 'sway/commands/focus.c')
-rw-r--r--sway/commands/focus.c25
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,
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;
- if (floating) {
- new_focus = ws->sway_workspace->floating;
- if (new_focus->children->length == 0) {
- return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+
+ // 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;
}
}
- seat_set_focus(seat, seat_get_active_child(seat, new_focus));
+
+ struct sway_container *new_focus = NULL;
+ if (floating) {
+ new_focus = seat_get_focus_inactive(seat, ws->sway_workspace->floating);
+ } else {
+ new_focus = seat_get_focus_inactive_tiling(seat, ws);
+ }
+ if (!new_focus) {
+ new_focus = ws;
+ }
+ seat_set_focus(seat, new_focus);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
@@ -97,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) {