Bugfix: Don't set input focus to window that has been closed
Patch status: needinfo
Patch by Marco Hunsicker
Long description:
This patch adjusts the point in time the focus is transferred when a window is closed to avoid having the input focus set (again) to the already detached window. Fixes #1185
To apply this patch, use:
curl http://cr.i3wm.org/patch/424/raw.patch | git am
b/src/tree.c
18 |
@@ -295,6 +295,27 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool |
19 |
con_fix_percent(parent); |
20 |
} |
21 |
|
22 |
+ if (next) { |
23 |
+ if (was_mapped || con == focused) { |
24 |
+ if ((kill_window != DONT_KILL_WINDOW) || !dont_kill_parent || con == focused) { |
25 |
+ DLOG("focusing %p / %s\n", next, next->name); |
26 |
+ if (next->type == CT_DOCKAREA) { |
27 |
+ /* Instead of focusing the dockarea, we need to restore focus to the workspace */ |
28 |
+ con_focus(con_descend_focused(output_get_content(next->parent))); |
29 |
+ } else { |
30 |
+ if (!force_set_focus && con != focused) |
31 |
+ DLOG("not changing focus, the container was not focused before\n"); |
32 |
+ else con_focus(next); |
33 |
+ } |
34 |
+ } |
35 |
+ else { |
36 |
+ DLOG("not focusing because we're not killing anybody\n"); |
37 |
+ } |
38 |
+ } else { |
39 |
+ DLOG("not focusing, was not mapped\n"); |
40 |
+ } |
41 |
+ } |
42 |
+ |
43 |
/* Render the tree so that the surrounding containers take up the space |
44 |
* which 'con' does no longer occupy. If we don’t render here, there will |
45 |
* be a gap in our containers and that could trigger an EnterNotify for an |
46 |
@@ -327,25 +348,6 @@ bool tree_close(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool |
47 |
return true; |
48 |
} |
49 |
|
50 |
- if (was_mapped || con == focused) { |
51 |
- if ((kill_window != DONT_KILL_WINDOW) || !dont_kill_parent || con == focused) { |
52 |
- DLOG("focusing %p / %s\n", next, next->name); |
53 |
- if (next->type == CT_DOCKAREA) { |
54 |
- /* Instead of focusing the dockarea, we need to restore focus to the workspace */ |
55 |
- con_focus(con_descend_focused(output_get_content(next->parent))); |
56 |
- } else { |
57 |
- if (!force_set_focus && con != focused) |
58 |
- DLOG("not changing focus, the container was not focused before\n"); |
59 |
- else con_focus(next); |
60 |
- } |
61 |
- } |
62 |
- else { |
63 |
- DLOG("not focusing because we're not killing anybody\n"); |
64 |
- } |
65 |
- } else { |
66 |
- DLOG("not focusing, was not mapped\n"); |
67 |
- } |
68 |
- |
69 |
/* check if the parent container is empty now and close it */ |
70 |
if (!dont_kill_parent) |
71 |
CALL(parent, on_remove_child); |