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).
next
Michael Stapelberg 2010-12-30 23:01:58 +01:00
parent f65e4f5b16
commit 50914e0483
1 changed files with 21 additions and 0 deletions

View File

@ -140,6 +140,16 @@ static void fix_floating_parent(Con *con, Con *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
*
@ -148,6 +158,13 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) {
bool was_mapped = con->mapped;
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 */
fix_floating_parent(croot, con);
@ -231,6 +248,10 @@ void tree_close_con() {
return;
}
/* There *should* be no possibility to focus outputs / root container */
assert(focused->type != CT_OUTPUT);
assert(focused->type != CT_ROOT);
/* Kill con */
tree_close(focused, true, false);
}