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/commands | |
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/commands')
-rw-r--r-- | sway/commands/focus.c | 5 | ||||
-rw-r--r-- | sway/commands/scratchpad.c | 5 | ||||
-rw-r--r-- | sway/commands/workspace.c | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 25df5130..6344a765 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -208,6 +208,11 @@ static struct cmd_results *focus_output(struct sway_seat *seat, "There is no output with that name"); } struct sway_workspace *ws = seat_get_focused_workspace(seat); + if (!ws) { + free(identifier); + return cmd_results_new(CMD_FAILURE, + "No focused workspace to base directions off of"); + } output = output_get_in_direction(ws->output, direction); if (!output) { diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index 71afa306..34871bc6 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -12,6 +12,11 @@ static void scratchpad_toggle_auto(void) { struct sway_seat *seat = input_manager_current_seat(); struct sway_container *focus = seat_get_focused_container(seat); struct sway_workspace *ws = seat_get_focused_workspace(seat); + if (!ws) { + sway_log(SWAY_DEBUG, + "No focused workspace to toggle scratchpad windows on"); + return; + } // If the focus is in a floating split container, // operate on the split container instead of the child. diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 362dcd1b..b911b2f6 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c @@ -185,8 +185,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { struct sway_seat *seat = config->handler_context.seat; struct sway_workspace *current = seat_get_focused_workspace(seat); if (!current) { - return cmd_results_new(CMD_FAILURE, "workspace", - "No workspace to switch from"); + return cmd_results_new(CMD_FAILURE, "No workspace to switch from"); } struct sway_workspace *ws = NULL; @@ -227,6 +226,9 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { } free(name); } + if (!ws) { + return cmd_results_new(CMD_FAILURE, "No workspace to switch to"); + } workspace_switch(ws, no_auto_back_and_forth); seat_consider_warp_to_focus(seat); } |