diff options
-rw-r--r-- | sway/commands/move.c | 16 | ||||
-rw-r--r-- | sway/workspace.c | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 00b57103..8d89f2ef 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "sway/output.h" | 7 | #include "sway/output.h" |
8 | #include "sway/workspace.h" | 8 | #include "sway/workspace.h" |
9 | #include "list.h" | 9 | #include "list.h" |
10 | #include "stringop.h" | ||
10 | 11 | ||
11 | struct cmd_results *cmd_move(int argc, char **argv) { | 12 | struct cmd_results *cmd_move(int argc, char **argv) { |
12 | struct cmd_results *error = NULL; | 13 | struct cmd_results *error = NULL; |
@@ -59,18 +60,23 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
59 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | 60 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); |
60 | } | 61 | } |
61 | 62 | ||
62 | const char *ws_name = argv[3]; | ||
63 | swayc_t *ws; | 63 | swayc_t *ws; |
64 | if (argc == 5 && strcasecmp(ws_name, "number") == 0) { | 64 | const char *num_name = NULL; |
65 | char *ws_name = NULL; | ||
66 | if (argc == 5 && strcasecmp(argv[3], "number") == 0) { | ||
65 | // move "container to workspace number x" | 67 | // move "container to workspace number x" |
66 | ws_name = argv[4]; | 68 | num_name = argv[4]; |
67 | ws = workspace_by_number(ws_name); | 69 | ws = workspace_by_number(num_name); |
68 | } else { | 70 | } else { |
71 | ws_name = join_args(argv + 3, argc - 3); | ||
69 | ws = workspace_by_name(ws_name); | 72 | ws = workspace_by_name(ws_name); |
70 | } | 73 | } |
71 | 74 | ||
72 | if (ws == NULL) { | 75 | if (ws == NULL) { |
73 | ws = workspace_create(ws_name); | 76 | ws = workspace_create(ws_name ? ws_name : num_name); |
77 | } | ||
78 | if (ws_name) { | ||
79 | free(ws_name); | ||
74 | } | 80 | } |
75 | move_container_to(view, get_focused_container(ws)); | 81 | move_container_to(view, get_focused_container(ws)); |
76 | } else if (strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "output") == 0) { | 82 | } else if (strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "output") == 0) { |
diff --git a/sway/workspace.c b/sway/workspace.c index 29cacce9..e0367190 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -61,7 +61,7 @@ char *workspace_next_name(const char *output_name) { | |||
61 | // workspace n | 61 | // workspace n |
62 | char *cmd = argsep(&cmdlist, " "); | 62 | char *cmd = argsep(&cmdlist, " "); |
63 | if (cmdlist) { | 63 | if (cmdlist) { |
64 | name = argsep(&cmdlist, " ,;"); | 64 | name = argsep(&cmdlist, ",;"); |
65 | } | 65 | } |
66 | 66 | ||
67 | if (strcmp("workspace", cmd) == 0 && name) { | 67 | if (strcmp("workspace", cmd) == 0 && name) { |