diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-03-12 13:57:40 -0400 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-03-12 19:14:04 +0100 |
commit | 3330faded5ed59b19b2a1982bb52c05322b03510 (patch) | |
tree | f6acaeb4793ff21534e84ea5b9b37bf87ddf7f91 /sway/tree | |
parent | a280facd5fb1c07dab97bbef1d8db534edf7dfa6 (diff) |
Handle seat_get_focused_workspace returning NULL
This modifiers the callers of seat_get_focused_workspace to handle
getting NULL as the return value, if they did not already.
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/root.c | 4 | ||||
-rw-r--r-- | sway/tree/workspace.c | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c index 6e13d6ce..0744192b 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -96,6 +96,10 @@ void root_scratchpad_remove_container(struct sway_container *con) { void root_scratchpad_show(struct sway_container *con) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *new_ws = seat_get_focused_workspace(seat); + if (!new_ws) { + sway_log(SWAY_DEBUG, "No focused workspace to show scratchpad on"); + return; + } struct sway_workspace *old_ws = con->workspace; // If the current con or any of its parents are in fullscreen mode, we diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 73322491..5e28197b 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -368,13 +368,13 @@ struct sway_workspace *workspace_by_name(const char *name) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *current = seat_get_focused_workspace(seat); - if (strcmp(name, "prev") == 0) { + if (current && strcmp(name, "prev") == 0) { return workspace_prev(current); - } else if (strcmp(name, "prev_on_output") == 0) { + } else if (current && strcmp(name, "prev_on_output") == 0) { return workspace_output_prev(current, false); - } else if (strcmp(name, "next") == 0) { + } else if (current && strcmp(name, "next") == 0) { return workspace_next(current); - } else if (strcmp(name, "next_on_output") == 0) { + } else if (current && strcmp(name, "next_on_output") == 0) { return workspace_output_next(current, false); } else if (strcmp(name, "current") == 0) { return current; @@ -399,6 +399,11 @@ static struct sway_workspace *workspace_output_prev_next_impl( struct sway_output *output, int dir, bool create) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *workspace = seat_get_focused_workspace(seat); + if (!workspace) { + sway_log(SWAY_DEBUG, + "No focused workspace to base prev/next on output off of"); + return NULL; + } int index = list_find(output->workspaces, workspace); if (!workspace_is_empty(workspace) && create && |