Bugfix: Correctly change focus when closing a split-container
The problem was i3 leaving an invalid focus pointer valid (after killing the container) because the container itself is not mapped (if it has no x11 window, for example split containers).
This commit is contained in:
parent
f65e4f5b16
commit
50914e0483
21
src/tree.c
21
src/tree.c
|
@ -140,6 +140,16 @@ static void fix_floating_parent(Con *con, Con *vanishing) {
|
||||||
fix_floating_parent(child, vanishing);
|
fix_floating_parent(child, vanishing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _is_con_mapped(Con *con) {
|
||||||
|
Con *child;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(child, &(con->nodes_head), nodes)
|
||||||
|
if (_is_con_mapped(child))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return con->mapped;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Closes the given container including all children
|
* Closes the given container including all children
|
||||||
*
|
*
|
||||||
|
@ -148,6 +158,13 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) {
|
||||||
bool was_mapped = con->mapped;
|
bool was_mapped = con->mapped;
|
||||||
Con *parent = con->parent;
|
Con *parent = con->parent;
|
||||||
|
|
||||||
|
if (!was_mapped) {
|
||||||
|
/* Even if the container itself is not mapped, its children may be
|
||||||
|
* mapped (for example split containers don't have a mapped window on
|
||||||
|
* their own but usually contain mapped children). */
|
||||||
|
was_mapped = _is_con_mapped(con);
|
||||||
|
}
|
||||||
|
|
||||||
/* check floating clients and adjust old_parent if necessary */
|
/* check floating clients and adjust old_parent if necessary */
|
||||||
fix_floating_parent(croot, con);
|
fix_floating_parent(croot, con);
|
||||||
|
|
||||||
|
@ -231,6 +248,10 @@ void tree_close_con() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* There *should* be no possibility to focus outputs / root container */
|
||||||
|
assert(focused->type != CT_OUTPUT);
|
||||||
|
assert(focused->type != CT_ROOT);
|
||||||
|
|
||||||
/* Kill con */
|
/* Kill con */
|
||||||
tree_close(focused, true, false);
|
tree_close(focused, true, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue