aboutsummaryrefslogtreecommitdiff
path: root/sway/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sway/layout.c b/sway/layout.c
index de7ef370..8ff5c4b7 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -60,8 +60,9 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) {
return parent;
}
-swayc_t *remove_child(swayc_t *parent, swayc_t *child) {
+swayc_t *remove_child(swayc_t *child) {
int i;
+ swayc_t *parent = child->parent;
// Special case for floating views
if (child->is_floating) {
for (i = 0; i < parent->floating->length; ++i) {
@@ -79,7 +80,11 @@ swayc_t *remove_child(swayc_t *parent, swayc_t *child) {
}
}
if (parent->focused == child) {
- parent->focused = NULL;
+ if (parent->children->length > 0) {
+ parent->focused = parent->children->items[i?i-1:0];
+ } else {
+ parent->focused = NULL;
+ }
}
return parent;
}