diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-08-06 10:43:09 +0100 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-08-06 14:17:58 +0100 |
commit | 667b8dcb67d8c3f15b52f59d228bb3146a5cdb30 (patch) | |
tree | f9873d108bd9c2f934112ea11e322656921a1f70 /sway/tree/workspace.c | |
parent | 3b1f58e1353f68ea10a3c5325ba4e04fbbe0c6a7 (diff) |
commands: check for special workspaces in workspace & move commands
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 5e20429b..3fcad631 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -251,34 +251,23 @@ struct sway_container *workspace_by_name(const char *name) { current_output = container_parent(focus, C_OUTPUT); } - char *name_cpy = strdup(name); - char *first_word = strtok(name_cpy, " "); - if (first_word == NULL) { - first_word = name_cpy; - } - - struct sway_container *ws = NULL; - if (strcmp(first_word, "prev") == 0) { - ws = workspace_prev(current_workspace); - } else if (strcmp(first_word, "prev_on_output") == 0) { - ws = workspace_output_prev(current_output); - } else if (strcmp(first_word, "next") == 0) { - ws = workspace_next(current_workspace); - } else if (strcmp(first_word, "next_on_output") == 0) { - ws = workspace_output_next(current_output); - } else if (strcmp(first_word, "current") == 0) { - ws = current_workspace; - } else if (strcasecmp(first_word, "back_and_forth") == 0) { - if (prev_workspace_name) { - ws = container_find(&root_container, _workspace_by_name, - (void *)prev_workspace_name); - } + if (strcmp(name, "prev") == 0) { + return workspace_prev(current_workspace); + } else if (strcmp(name, "prev_on_output") == 0) { + return workspace_output_prev(current_output); + } else if (strcmp(name, "next") == 0) { + return workspace_next(current_workspace); + } else if (strcmp(name, "next_on_output") == 0) { + return workspace_output_next(current_output); + } else if (strcmp(name, "current") == 0) { + return current_workspace; + } else if (strcasecmp(name, "back_and_forth") == 0) { + return prev_workspace_name ? container_find(&root_container, + _workspace_by_name, (void *)prev_workspace_name) : NULL; } else { - ws = container_find(&root_container, _workspace_by_name, + return container_find(&root_container, _workspace_by_name, (void *)name); } - free(name_cpy); - return ws; } /** |