Merge branch 'fix-close-focus'
This commit is contained in:
commit
ef0f4e7299
|
@ -70,8 +70,15 @@ void tree_next(char way, orientation_t orientation);
|
|||
* Returns true if the container was killed or false if just WM_DELETE was sent
|
||||
* and the window is expected to kill itself.
|
||||
*
|
||||
* The dont_kill_parent flag is specified when the function calls itself
|
||||
* recursively while deleting a containers children.
|
||||
*
|
||||
* The force_set_focus flag is specified in the case of killing a floating
|
||||
* window: tree_close() will be invoked for the CT_FLOATINGCON (the parent
|
||||
* container) and focus should be set there.
|
||||
*
|
||||
*/
|
||||
bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent);
|
||||
bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus);
|
||||
|
||||
/**
|
||||
* Loads tree from ~/.i3/_restart.json (used for in-place restarts).
|
||||
|
|
|
@ -533,7 +533,7 @@ kill:
|
|||
else {
|
||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||
printf("matching: %p / %s\n", current->con, current->con->name);
|
||||
tree_close(current->con, $2, false);
|
||||
tree_close(current->con, $2, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1021,7 +1021,7 @@ static void con_on_remove_child(Con *con) {
|
|||
int children = con_num_children(con);
|
||||
if (children == 0) {
|
||||
DLOG("Container empty, closing\n");
|
||||
tree_close(con, DONT_KILL_WINDOW, false);
|
||||
tree_close(con, DONT_KILL_WINDOW, false, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ void floating_enable(Con *con, bool automatic) {
|
|||
/* check if the parent container is empty and close it if so */
|
||||
if ((con->parent->type == CT_CON || con->parent->type == CT_FLOATING_CON) && con_num_children(con->parent) == 0) {
|
||||
DLOG("Old container empty after setting this child to floating, closing\n");
|
||||
tree_close(con->parent, DONT_KILL_WINDOW, false);
|
||||
tree_close(con->parent, DONT_KILL_WINDOW, false, false);
|
||||
}
|
||||
|
||||
char *name;
|
||||
|
@ -212,7 +212,7 @@ void floating_disable(Con *con, bool automatic) {
|
|||
/* 2: kill parent container */
|
||||
TAILQ_REMOVE(&(con->parent->parent->floating_head), con->parent, floating_windows);
|
||||
TAILQ_REMOVE(&(con->parent->parent->focus_head), con->parent, focused);
|
||||
tree_close(con->parent, DONT_KILL_WINDOW, false);
|
||||
tree_close(con->parent, DONT_KILL_WINDOW, false, false);
|
||||
|
||||
/* 3: re-attach to the parent of the currently focused con on the workspace
|
||||
* this floating con was on */
|
||||
|
|
|
@ -457,7 +457,7 @@ static int handle_unmap_notify_event(xcb_unmap_notify_event_t *event) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
tree_close(con, DONT_KILL_WINDOW, false);
|
||||
tree_close(con, DONT_KILL_WINDOW, false, false);
|
||||
tree_render();
|
||||
x_push_changes(croot);
|
||||
return 1;
|
||||
|
|
|
@ -789,7 +789,7 @@ void randr_query_outputs() {
|
|||
}
|
||||
|
||||
DLOG("destroying disappearing con %p\n", output->con);
|
||||
tree_close(output->con, DONT_KILL_WINDOW, true);
|
||||
tree_close(output->con, DONT_KILL_WINDOW, true, false);
|
||||
DLOG("Done. Should be fine now\n");
|
||||
output->con = NULL;
|
||||
}
|
||||
|
|
19
src/tree.c
19
src/tree.c
|
@ -114,8 +114,15 @@ static bool _is_con_mapped(Con *con) {
|
|||
* Returns true if the container was killed or false if just WM_DELETE was sent
|
||||
* and the window is expected to kill itself.
|
||||
*
|
||||
* The dont_kill_parent flag is specified when the function calls itself
|
||||
* recursively while deleting a containers children.
|
||||
*
|
||||
* The force_set_focus flag is specified in the case of killing a floating
|
||||
* window: tree_close() will be invoked for the CT_FLOATINGCON (the parent
|
||||
* container) and focus should be set there.
|
||||
*
|
||||
*/
|
||||
bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
|
||||
bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus) {
|
||||
bool was_mapped = con->mapped;
|
||||
Con *parent = con->parent;
|
||||
|
||||
|
@ -138,7 +145,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
|
|||
for (child = TAILQ_FIRST(&(con->nodes_head)); child; ) {
|
||||
nextchild = TAILQ_NEXT(child, nodes);
|
||||
DLOG("killing child=%p\n", child);
|
||||
if (!tree_close(child, kill_window, true))
|
||||
if (!tree_close(child, kill_window, true, false))
|
||||
abort_kill = true;
|
||||
child = nextchild;
|
||||
}
|
||||
|
@ -191,7 +198,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
|
|||
if (con_is_floating(con)) {
|
||||
Con *ws = con_get_workspace(con);
|
||||
DLOG("Container was floating, killing floating container\n");
|
||||
tree_close(parent, DONT_KILL_WINDOW, false);
|
||||
tree_close(parent, DONT_KILL_WINDOW, false, (con == focused));
|
||||
DLOG("parent container killed\n");
|
||||
if (con == focused) {
|
||||
DLOG("This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
|
||||
|
@ -224,7 +231,7 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent) {
|
|||
/* Instead of focusing the dockarea, we need to restore focus to the workspace */
|
||||
con_focus(con_descend_focused(output_get_content(next->parent)));
|
||||
} else {
|
||||
if (con != focused)
|
||||
if (!force_set_focus && con != focused)
|
||||
DLOG("not changing focus, the container was not focused before\n");
|
||||
else con_focus(next);
|
||||
}
|
||||
|
@ -259,7 +266,7 @@ void tree_close_con(kill_window_t kill_window) {
|
|||
assert(focused->type != CT_ROOT);
|
||||
|
||||
/* Kill con */
|
||||
tree_close(focused, kill_window, false);
|
||||
tree_close(focused, kill_window, false, false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -549,7 +556,7 @@ void tree_flatten(Con *con) {
|
|||
|
||||
/* 4: close the redundant cons */
|
||||
DLOG("closing redundant cons\n");
|
||||
tree_close(con, DONT_KILL_WINDOW, true);
|
||||
tree_close(con, DONT_KILL_WINDOW, true, false);
|
||||
|
||||
/* Well, we got to abort the recursion here because we destroyed the
|
||||
* container. However, if tree_flatten() is called sufficiently often,
|
||||
|
|
|
@ -211,7 +211,7 @@ void workspace_show(const char *num) {
|
|||
/* check if this workspace is currently visible */
|
||||
if (!workspace_is_visible(old)) {
|
||||
LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name);
|
||||
tree_close(old, DONT_KILL_WINDOW, false);
|
||||
tree_close(old, DONT_KILL_WINDOW, false, false);
|
||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"empty\"}");
|
||||
changed_num_workspaces = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue