aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-10-06 08:58:29 -0400
committerLibravatar GitHub <noreply@github.com>2017-10-06 08:58:29 -0400
commitfff684b98eb9a06e915f9b7dd9ebce1ceb95dede (patch)
tree4850489604dd7c55716044c8210dbeea1b7bb10f
parentMerge pull request #1383 from kasicka/macarena (diff)
parentMake `workspace_next_name` work with spaces (diff)
downloadsway-fff684b98eb9a06e915f9b7dd9ebce1ceb95dede.tar.gz
sway-fff684b98eb9a06e915f9b7dd9ebce1ceb95dede.tar.zst
sway-fff684b98eb9a06e915f9b7dd9ebce1ceb95dede.zip
Merge pull request #1384 from lbonn/move-workspace-fullname
Fix two issues with spaces in workspace names
-rw-r--r--sway/commands/move.c16
-rw-r--r--sway/workspace.c2
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
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) {
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) {