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 | commands: document <criteria> focus (diff) | |
download | sway-667b8dcb67d8c3f15b52f59d228bb3146a5cdb30.tar.gz sway-667b8dcb67d8c3f15b52f59d228bb3146a5cdb30.tar.zst sway-667b8dcb67d8c3f15b52f59d228bb3146a5cdb30.zip |
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) { | |||
251 | current_output = container_parent(focus, C_OUTPUT); | 251 | current_output = container_parent(focus, C_OUTPUT); |
252 | } | 252 | } |
253 | 253 | ||
254 | char *name_cpy = strdup(name); | 254 | if (strcmp(name, "prev") == 0) { |
255 | char *first_word = strtok(name_cpy, " "); | 255 | return workspace_prev(current_workspace); |
256 | if (first_word == NULL) { | 256 | } else if (strcmp(name, "prev_on_output") == 0) { |
257 | first_word = name_cpy; | 257 | return workspace_output_prev(current_output); |
258 | } | 258 | } else if (strcmp(name, "next") == 0) { |
259 | 259 | return workspace_next(current_workspace); | |
260 | struct sway_container *ws = NULL; | 260 | } else if (strcmp(name, "next_on_output") == 0) { |
261 | if (strcmp(first_word, "prev") == 0) { | 261 | return workspace_output_next(current_output); |
262 | ws = workspace_prev(current_workspace); | 262 | } else if (strcmp(name, "current") == 0) { |
263 | } else if (strcmp(first_word, "prev_on_output") == 0) { | 263 | return current_workspace; |
264 | ws = workspace_output_prev(current_output); | 264 | } else if (strcasecmp(name, "back_and_forth") == 0) { |
265 | } else if (strcmp(first_word, "next") == 0) { | 265 | return prev_workspace_name ? container_find(&root_container, |
266 | ws = workspace_next(current_workspace); | 266 | _workspace_by_name, (void *)prev_workspace_name) : NULL; |
267 | } else if (strcmp(first_word, "next_on_output") == 0) { | ||
268 | ws = workspace_output_next(current_output); | ||
269 | } else if (strcmp(first_word, "current") == 0) { | ||
270 | ws = current_workspace; | ||
271 | } else if (strcasecmp(first_word, "back_and_forth") == 0) { | ||
272 | if (prev_workspace_name) { | ||
273 | ws = container_find(&root_container, _workspace_by_name, | ||
274 | (void *)prev_workspace_name); | ||
275 | } | ||
276 | } else { | 267 | } else { |
277 | ws = container_find(&root_container, _workspace_by_name, | 268 | return container_find(&root_container, _workspace_by_name, |
278 | (void *)name); | 269 | (void *)name); |
279 | } | 270 | } |
280 | free(name_cpy); | ||
281 | return ws; | ||
282 | } | 271 | } |
283 | 272 | ||
284 | /** | 273 | /** |