aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar lbonn <bonnans.l@gmail.com>2017-10-06 14:16:24 +0200
committerLibravatar lbonn <bonnans.l@gmail.com>2017-10-06 14:16:24 +0200
commit6197fff0b4b6783362f2e2673fdc0827c5948a4a (patch)
treea6b1b04c64e36b93f6c5807fc581280a9f643ead
parentMerge pull request #1383 from kasicka/macarena (diff)
downloadsway-6197fff0b4b6783362f2e2673fdc0827c5948a4a.tar.gz
sway-6197fff0b4b6783362f2e2673fdc0827c5948a4a.tar.zst
sway-6197fff0b4b6783362f2e2673fdc0827c5948a4a.zip
Fix move to named workspaces
The command parsing did not handle workspaces with spaces in their name (like it's done in `cmd_workspace`)
-rw-r--r--sway/commands/move.c16
1 files changed, 11 insertions, 5 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
11struct cmd_results *cmd_move(int argc, char **argv) { 12struct 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) {