From e7261e291766f6cbfb947ded4906ed8e6664b7bd Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 6 Jun 2018 16:41:19 -0400 Subject: [PATCH 1/2] Fix focusing after splitting tabs/stacks --- sway/tree/layout.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 79e7c87e..fe0243b6 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -874,11 +874,10 @@ struct sway_container *container_split(struct sway_container *child, cont->x = child->x; cont->y = child->y; + struct sway_seat *seat = input_manager_get_default_seat(input_manager); + bool set_focus = (seat_get_focus(seat) == child); if (child->type == C_WORKSPACE) { - struct sway_seat *seat = input_manager_get_default_seat(input_manager); struct sway_container *workspace = child; - bool set_focus = (seat_get_focus(seat) == workspace); - while (workspace->children->length) { struct sway_container *ws_child = workspace->children->items[0]; container_remove_child(ws_child); @@ -890,10 +889,6 @@ struct sway_container *container_split(struct sway_container *child, enum sway_container_layout old_layout = workspace->layout; workspace->layout = layout; cont->layout = old_layout; - - if (set_focus) { - seat_set_focus(seat, cont); - } } else { struct sway_container *old_parent = child->parent; cont->layout = layout; @@ -902,6 +897,14 @@ struct sway_container *container_split(struct sway_container *child, wl_signal_emit(&child->events.reparent, old_parent); } + if (set_focus) { + seat_set_focus(seat, cont); + if (cont->parent->layout == L_TABBED + || cont->parent->layout == L_STACKED) { + seat_set_focus(seat, child); + } + } + container_notify_subtree_changed(cont); return cont; From 82b3b587dd2b64117f4b138437b5ac29bda19fe8 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 6 Jun 2018 19:38:38 -0400 Subject: [PATCH 2/2] Remove tab/stack check for focusing after a split --- sway/tree/layout.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sway/tree/layout.c b/sway/tree/layout.c index fe0243b6..82502e1b 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -899,10 +899,7 @@ struct sway_container *container_split(struct sway_container *child, if (set_focus) { seat_set_focus(seat, cont); - if (cont->parent->layout == L_TABBED - || cont->parent->layout == L_STACKED) { - seat_set_focus(seat, child); - } + seat_set_focus(seat, child); } container_notify_subtree_changed(cont);