From d202ca2fd7c1be75ea9a4f122a3cc18fabde16e8 Mon Sep 17 00:00:00 2001 From: David Eklov Date: Sun, 17 Jul 2016 22:47:20 -0500 Subject: [PATCH 1/2] Do not crash when handling the command 'move position' Sway expected 'move position' to be 'move position mouse'. If mouse is not present in the command, Sway crashes. --- sway/commands.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index 73f245c13..1dec9889f 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1115,7 +1115,14 @@ static struct cmd_results *cmd_move(int argc, char **argv) { focused = swayc_active_workspace(); } set_focused_container(focused); - } else if (strcasecmp(argv[0], "position") == 0 && strcasecmp(argv[1], "mouse") == 0) { + } else if (strcasecmp(argv[0], "position") == 0) { + if ((error = checkarg(argc, "move workspace", EXPECTED_EQUAL_TO, 2))) { + return error; + } + if (strcasecmp(argv[1], "mouse")) { + return cmd_results_new(CMD_INVALID, "move", expected_syntax); + } + if (view->is_floating) { swayc_t *output = swayc_parent_by_type(view, C_OUTPUT); struct wlc_geometry g; From d9eb49f3b1b07a06300c40cb4dae0535279d0302 Mon Sep 17 00:00:00 2001 From: David Eklov Date: Sun, 17 Jul 2016 22:52:39 -0500 Subject: [PATCH 2/2] Add missing entry to list of accepted arguments for the move command --- sway/commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index 1dec9889f..aaacf0fc1 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1011,7 +1011,8 @@ static struct cmd_results *cmd_move(int argc, char **argv) { } const char* expected_syntax = "Expected 'move ' or " "'move to workspace ' or " - "'move to output '"; + "'move to output ' or " + "'move position mouse'"; swayc_t *view = get_focused_container(&root_container); if (strcasecmp(argv[0], "left") == 0) {