diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-28 12:57:58 -0500 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-28 13:02:54 -0500 |
commit | f52277f66e85d13589b51a851b9e97c3457ed654 (patch) | |
tree | b377b8b22ac59ab8cd40285d731f45b57d6f1c93 /sway/tree/root.c | |
parent | 5341e034df75f387184f85cb6a5fc0c95faf537e (diff) |
Fix scratchpad segfault - NULL focused workspace
When adding a container to the scratchpad, it was possible for focus to
be removed from the seat. This occurred when a single child was moved
from it's parent to the scratchpad due to the focus_inactive for the
parent being NULL. If the focus_inactive for the parent is NULL, the
focus_inactive for the workspace should be focused.
Diffstat (limited to 'sway/tree/root.c')
-rw-r--r-- | sway/tree/root.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c index 9f6bf607..22c46aba 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -69,13 +69,16 @@ void root_scratchpad_add_container(struct sway_container *con) { list_add(root->scratchpad, con); struct sway_seat *seat = input_manager_current_seat(); + struct sway_node *new_focus = NULL; if (parent) { arrange_container(parent); - seat_set_focus(seat, seat_get_focus_inactive(seat, &parent->node)); - } else { + new_focus = seat_get_focus_inactive(seat, &parent->node); + } + if (!new_focus) { arrange_workspace(workspace); - seat_set_focus(seat, seat_get_focus_inactive(seat, &workspace->node)); + new_focus = seat_get_focus_inactive(seat, &workspace->node); } + seat_set_focus(seat, new_focus); ipc_event_window(con, "move"); } |