diff options
author | Nicolas Avrutin <nicolas@avrutin.net> | 2022-03-06 19:38:03 -0500 |
---|---|---|
committer | Ronan Pigott <rpigott@berkeley.edu> | 2022-03-06 18:24:16 -0700 |
commit | 9f98c38d3e02b0187de31a434cc4315a22834593 (patch) | |
tree | 906e2f25726491783f78bdf90ed9ac8e18985647 /sway | |
parent | 3444ce730230d281c9db49e2c808710192e69888 (diff) |
commands/focus: fix segfault when no container is already focused.
Fixes #6690.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/focus.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 2e8584c9..facd82de 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -285,7 +285,7 @@ static struct cmd_results *focus_mode(struct sway_workspace *ws, } } else { return cmd_results_new(CMD_FAILURE, - "Failed to find a %s container in workspace", + "Failed to find a %s container in workspace.", floating ? "floating" : "tiling"); } return cmd_results_new(CMD_SUCCESS, NULL); @@ -295,7 +295,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat, int argc, char **argv) { if (!argc) { return cmd_results_new(CMD_INVALID, - "Expected 'focus output <direction|name>'"); + "Expected 'focus output <direction|name>'."); } char *identifier = join_args(argv, argc); struct sway_output *output = output_by_name_or_id(identifier); @@ -305,13 +305,13 @@ static struct cmd_results *focus_output(struct sway_seat *seat, if (!parse_direction(identifier, &direction)) { free(identifier); return cmd_results_new(CMD_INVALID, - "There is no output with that name"); + "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"); + "No focused workspace to base directions off of."); } output = output_get_in_direction(ws->output, direction); @@ -375,10 +375,14 @@ struct cmd_results *cmd_focus(int argc, char **argv) { struct sway_seat *seat = config->handler_context.seat; if (node->type < N_WORKSPACE) { return cmd_results_new(CMD_FAILURE, - "Command 'focus' cannot be used above the workspace level"); + "Command 'focus' cannot be used above the workspace level."); } - if (argc == 0 && container) { + if (argc == 0) { + if (!container) { + return cmd_results_new(CMD_FAILURE, "No container to focus was specified."); + } + if (container_is_scratchpad_hidden_or_child(container)) { root_scratchpad_show(container); } |