From 9190735947947f5afa21f725cfe0569abde946aa Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 13 Oct 2018 19:15:04 +1000 Subject: Fix crash when view maps while locked When locked, there is no active workspace so it must find the focus_inactive workspace instead. Additionally, this adds a check for if a view maps while there are no outputs connected and handles it gracefully. --- sway/tree/view.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sway/tree/view.c') diff --git a/sway/tree/view.c b/sway/tree/view.c index e613ac0b..1104af36 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -504,7 +504,16 @@ static struct sway_workspace *select_workspace(struct sway_view *view) { } // Use the focused workspace - return seat_get_focused_workspace(seat); + struct sway_node *node = seat_get_focus_inactive(seat, &root->node); + if (node && node->type == N_WORKSPACE) { + return node->sway_workspace; + } else if (node && node->type == N_CONTAINER) { + return node->sway_container->workspace; + } + + // If there's no focus_inactive workspace then we must be running without + // any outputs connected + return root->saved_workspaces->items[0]; } static bool should_focus(struct sway_view *view) { -- cgit v1.2.3