diff options
author | 2021-06-18 17:05:23 +0200 | |
---|---|---|
committer | 2021-06-22 19:00:31 +0200 | |
commit | c0c4e260c45a07b98fc90276a9ca7b6cf06b3d0b (patch) | |
tree | 3035de0f58cbaf2a0bffcbd42ab6ec94db060086 | |
parent | Don't apply hide_edge_borders to any floating container (diff) | |
download | sway-c0c4e260c45a07b98fc90276a9ca7b6cf06b3d0b.tar.gz sway-c0c4e260c45a07b98fc90276a9ca7b6cf06b3d0b.tar.zst sway-c0c4e260c45a07b98fc90276a9ca7b6cf06b3d0b.zip |
Revert "Add workspace {prev,next}_on_output --create"
This reverts commit 487c83f0de9ca2a7650ad636eed6fd694ddcb82e.
The --create flag is undocumented, not in i3, and at least partially
broken (#5913), so this removes the feature.
-rw-r--r-- | include/sway/tree/workspace.h | 6 | ||||
-rw-r--r-- | sway/commands/workspace.c | 11 | ||||
-rw-r--r-- | sway/tree/workspace.c | 30 |
3 files changed, 14 insertions, 33 deletions
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 65ba247f..b3d93a81 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h | |||
@@ -69,13 +69,11 @@ struct sway_workspace *workspace_by_number(const char* name); | |||
69 | 69 | ||
70 | struct sway_workspace *workspace_by_name(const char*); | 70 | struct sway_workspace *workspace_by_name(const char*); |
71 | 71 | ||
72 | struct sway_workspace *workspace_output_next( | 72 | struct sway_workspace *workspace_output_next(struct sway_workspace *current); |
73 | struct sway_workspace *current, bool create); | ||
74 | 73 | ||
75 | struct sway_workspace *workspace_next(struct sway_workspace *current); | 74 | struct sway_workspace *workspace_next(struct sway_workspace *current); |
76 | 75 | ||
77 | struct sway_workspace *workspace_output_prev( | 76 | struct sway_workspace *workspace_output_prev(struct sway_workspace *current); |
78 | struct sway_workspace *current, bool create); | ||
79 | 77 | ||
80 | struct sway_workspace *workspace_prev(struct sway_workspace *current); | 78 | struct sway_workspace *workspace_prev(struct sway_workspace *current); |
81 | 79 | ||
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 67db08ff..a6a0beda 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -187,12 +187,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
187 | ++argv; | 187 | ++argv; |
188 | } | 188 | } |
189 | 189 | ||
190 | bool create = argc > 1 && strcasecmp(argv[1], "--create") == 0; | ||
191 | struct sway_seat *seat = config->handler_context.seat; | 190 | struct sway_seat *seat = config->handler_context.seat; |
192 | struct sway_workspace *current = seat_get_focused_workspace(seat); | ||
193 | if (!current) { | ||
194 | return cmd_results_new(CMD_FAILURE, "No workspace to switch from"); | ||
195 | } | ||
196 | 191 | ||
197 | struct sway_workspace *ws = NULL; | 192 | struct sway_workspace *ws = NULL; |
198 | if (strcasecmp(argv[0], "number") == 0) { | 193 | if (strcasecmp(argv[0], "number") == 0) { |
@@ -214,12 +209,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
214 | } | 209 | } |
215 | } else if (strcasecmp(argv[0], "next") == 0 || | 210 | } else if (strcasecmp(argv[0], "next") == 0 || |
216 | strcasecmp(argv[0], "prev") == 0 || | 211 | strcasecmp(argv[0], "prev") == 0 || |
212 | strcasecmp(argv[0], "next_on_output") == 0 || | ||
213 | strcasecmp(argv[0], "prev_on_output") == 0 || | ||
217 | strcasecmp(argv[0], "current") == 0) { | 214 | strcasecmp(argv[0], "current") == 0) { |
218 | ws = workspace_by_name(argv[0]); | 215 | ws = workspace_by_name(argv[0]); |
219 | } else if (strcasecmp(argv[0], "next_on_output") == 0) { | ||
220 | ws = workspace_output_next(current, create); | ||
221 | } else if (strcasecmp(argv[0], "prev_on_output") == 0) { | ||
222 | ws = workspace_output_prev(current, create); | ||
223 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { | 216 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { |
224 | if (!seat->prev_workspace_name) { | 217 | if (!seat->prev_workspace_name) { |
225 | return cmd_results_new(CMD_INVALID, | 218 | return cmd_results_new(CMD_INVALID, |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 7e98dc92..8dd7789d 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -222,10 +222,8 @@ static void workspace_name_from_binding(const struct sway_binding * binding, | |||
222 | // not a command about workspaces | 222 | // not a command about workspaces |
223 | if (strcmp(_target, "next") == 0 || | 223 | if (strcmp(_target, "next") == 0 || |
224 | strcmp(_target, "prev") == 0 || | 224 | strcmp(_target, "prev") == 0 || |
225 | strncmp(_target, "next_on_output", | 225 | strcmp(_target, "next_on_output") == 0 || |
226 | strlen("next_on_output")) == 0 || | 226 | strcmp(_target, "prev_on_output") == 0 || |
227 | strncmp(_target, "prev_on_output", | ||
228 | strlen("next_on_output")) == 0 || | ||
229 | strcmp(_target, "number") == 0 || | 227 | strcmp(_target, "number") == 0 || |
230 | strcmp(_target, "back_and_forth") == 0 || | 228 | strcmp(_target, "back_and_forth") == 0 || |
231 | strcmp(_target, "current") == 0) { | 229 | strcmp(_target, "current") == 0) { |
@@ -363,11 +361,11 @@ struct sway_workspace *workspace_by_name(const char *name) { | |||
363 | if (current && strcmp(name, "prev") == 0) { | 361 | if (current && strcmp(name, "prev") == 0) { |
364 | return workspace_prev(current); | 362 | return workspace_prev(current); |
365 | } else if (current && strcmp(name, "prev_on_output") == 0) { | 363 | } else if (current && strcmp(name, "prev_on_output") == 0) { |
366 | return workspace_output_prev(current, false); | 364 | return workspace_output_prev(current); |
367 | } else if (current && strcmp(name, "next") == 0) { | 365 | } else if (current && strcmp(name, "next") == 0) { |
368 | return workspace_next(current); | 366 | return workspace_next(current); |
369 | } else if (current && strcmp(name, "next_on_output") == 0) { | 367 | } else if (current && strcmp(name, "next_on_output") == 0) { |
370 | return workspace_output_next(current, false); | 368 | return workspace_output_next(current); |
371 | } else if (strcmp(name, "current") == 0) { | 369 | } else if (strcmp(name, "current") == 0) { |
372 | return current; | 370 | return current; |
373 | } else if (strcasecmp(name, "back_and_forth") == 0) { | 371 | } else if (strcasecmp(name, "back_and_forth") == 0) { |
@@ -530,7 +528,7 @@ struct sway_workspace *workspace_next(struct sway_workspace *workspace) { | |||
530 | * otherwise the next one is returned. | 528 | * otherwise the next one is returned. |
531 | */ | 529 | */ |
532 | static struct sway_workspace *workspace_output_prev_next_impl( | 530 | static struct sway_workspace *workspace_output_prev_next_impl( |
533 | struct sway_output *output, int dir, bool create) { | 531 | struct sway_output *output, int dir) { |
534 | struct sway_seat *seat = input_manager_current_seat(); | 532 | struct sway_seat *seat = input_manager_current_seat(); |
535 | struct sway_workspace *workspace = seat_get_focused_workspace(seat); | 533 | struct sway_workspace *workspace = seat_get_focused_workspace(seat); |
536 | if (!workspace) { | 534 | if (!workspace) { |
@@ -540,25 +538,17 @@ static struct sway_workspace *workspace_output_prev_next_impl( | |||
540 | } | 538 | } |
541 | 539 | ||
542 | int index = list_find(output->workspaces, workspace); | 540 | int index = list_find(output->workspaces, workspace); |
543 | if (!workspace_is_empty(workspace) && create && | ||
544 | (index + dir < 0 || index + dir == output->workspaces->length)) { | ||
545 | struct sway_output *output = workspace->output; | ||
546 | char *next = workspace_next_name(output->wlr_output->name); | ||
547 | workspace_create(output, next); | ||
548 | free(next); | ||
549 | } | ||
550 | size_t new_index = wrap(index + dir, output->workspaces->length); | 541 | size_t new_index = wrap(index + dir, output->workspaces->length); |
551 | return output->workspaces->items[new_index]; | 542 | return output->workspaces->items[new_index]; |
552 | } | 543 | } |
553 | 544 | ||
554 | struct sway_workspace *workspace_output_next( | 545 | |
555 | struct sway_workspace *current, bool create) { | 546 | struct sway_workspace *workspace_output_next(struct sway_workspace *current) { |
556 | return workspace_output_prev_next_impl(current->output, 1, create); | 547 | return workspace_output_prev_next_impl(current->output, 1); |
557 | } | 548 | } |
558 | 549 | ||
559 | struct sway_workspace *workspace_output_prev( | 550 | struct sway_workspace *workspace_output_prev(struct sway_workspace *current) { |
560 | struct sway_workspace *current, bool create) { | 551 | return workspace_output_prev_next_impl(current->output, -1); |
561 | return workspace_output_prev_next_impl(current->output, -1, create); | ||
562 | } | 552 | } |
563 | 553 | ||
564 | struct sway_workspace *workspace_auto_back_and_forth( | 554 | struct sway_workspace *workspace_auto_back_and_forth( |