diff options
-rw-r--r-- | include/sway/tree/workspace.h | 6 | ||||
-rw-r--r-- | sway/commands/workspace.c | 14 | ||||
-rw-r--r-- | sway/tree/workspace.c | 20 |
3 files changed, 25 insertions, 15 deletions
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index fdd92f64..65ba247f 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h | |||
@@ -60,8 +60,10 @@ void workspace_consider_destroy(struct sway_workspace *ws); | |||
60 | 60 | ||
61 | char *workspace_next_name(const char *output_name); | 61 | char *workspace_next_name(const char *output_name); |
62 | 62 | ||
63 | bool workspace_switch(struct sway_workspace *workspace, | 63 | struct sway_workspace *workspace_auto_back_and_forth( |
64 | bool no_auto_back_and_forth); | 64 | struct sway_workspace *workspace); |
65 | |||
66 | bool workspace_switch(struct sway_workspace *workspace); | ||
65 | 67 | ||
66 | struct sway_workspace *workspace_by_number(const char* name); | 68 | struct sway_workspace *workspace_by_number(const char* name); |
67 | 69 | ||
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index bf6b7e04..c253c75d 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -178,9 +178,9 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
178 | "Can't switch workspaces while fullscreen global"); | 178 | "Can't switch workspaces while fullscreen global"); |
179 | } | 179 | } |
180 | 180 | ||
181 | bool no_auto_back_and_forth = false; | 181 | bool auto_back_and_forth = true; |
182 | while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) { | 182 | while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) { |
183 | no_auto_back_and_forth = true; | 183 | auto_back_and_forth = false; |
184 | if ((error = checkarg(--argc, "workspace", EXPECTED_AT_LEAST, 1))) { | 184 | if ((error = checkarg(--argc, "workspace", EXPECTED_AT_LEAST, 1))) { |
185 | return error; | 185 | return error; |
186 | } | 186 | } |
@@ -215,10 +215,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
215 | ws = workspace_by_name(argv[0]); | 215 | ws = workspace_by_name(argv[0]); |
216 | } else if (strcasecmp(argv[0], "next_on_output") == 0) { | 216 | } else if (strcasecmp(argv[0], "next_on_output") == 0) { |
217 | ws = workspace_output_next(current, create); | 217 | ws = workspace_output_next(current, create); |
218 | no_auto_back_and_forth = true; | 218 | auto_back_and_forth = false; |
219 | } else if (strcasecmp(argv[0], "prev_on_output") == 0) { | 219 | } else if (strcasecmp(argv[0], "prev_on_output") == 0) { |
220 | ws = workspace_output_prev(current, create); | 220 | ws = workspace_output_prev(current, create); |
221 | no_auto_back_and_forth = true; | 221 | auto_back_and_forth = false; |
222 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { | 222 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { |
223 | if (!seat->prev_workspace_name) { | 223 | if (!seat->prev_workspace_name) { |
224 | return cmd_results_new(CMD_INVALID, | 224 | return cmd_results_new(CMD_INVALID, |
@@ -227,6 +227,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
227 | if (!(ws = workspace_by_name(argv[0]))) { | 227 | if (!(ws = workspace_by_name(argv[0]))) { |
228 | ws = workspace_create(NULL, seat->prev_workspace_name); | 228 | ws = workspace_create(NULL, seat->prev_workspace_name); |
229 | } | 229 | } |
230 | auto_back_and_forth = false; | ||
230 | } else { | 231 | } else { |
231 | char *name = join_args(argv, argc); | 232 | char *name = join_args(argv, argc); |
232 | if (!(ws = workspace_by_name(name))) { | 233 | if (!(ws = workspace_by_name(name))) { |
@@ -237,7 +238,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
237 | if (!ws) { | 238 | if (!ws) { |
238 | return cmd_results_new(CMD_FAILURE, "No workspace to switch to"); | 239 | return cmd_results_new(CMD_FAILURE, "No workspace to switch to"); |
239 | } | 240 | } |
240 | workspace_switch(ws, no_auto_back_and_forth); | 241 | if(auto_back_and_forth){ |
242 | ws = workspace_auto_back_and_forth(ws); | ||
243 | } | ||
244 | workspace_switch(ws); | ||
241 | seat_consider_warp_to_focus(seat); | 245 | seat_consider_warp_to_focus(seat); |
242 | } | 246 | } |
243 | return cmd_results_new(CMD_SUCCESS, NULL); | 247 | return cmd_results_new(CMD_SUCCESS, NULL); |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index c0da9c93..2dbd6346 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -561,8 +561,8 @@ struct sway_workspace *workspace_output_prev( | |||
561 | return workspace_output_prev_next_impl(current->output, -1, create); | 561 | return workspace_output_prev_next_impl(current->output, -1, create); |
562 | } | 562 | } |
563 | 563 | ||
564 | bool workspace_switch(struct sway_workspace *workspace, | 564 | struct sway_workspace *workspace_auto_back_and_forth( |
565 | bool no_auto_back_and_forth) { | 565 | struct sway_workspace *workspace) { |
566 | struct sway_seat *seat = input_manager_current_seat(); | 566 | struct sway_seat *seat = input_manager_current_seat(); |
567 | struct sway_workspace *active_ws = NULL; | 567 | struct sway_workspace *active_ws = NULL; |
568 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); | 568 | struct sway_node *focus = seat_get_focus_inactive(seat, &root->node); |
@@ -572,14 +572,18 @@ bool workspace_switch(struct sway_workspace *workspace, | |||
572 | active_ws = focus->sway_container->pending.workspace; | 572 | active_ws = focus->sway_container->pending.workspace; |
573 | } | 573 | } |
574 | 574 | ||
575 | if (!no_auto_back_and_forth && config->auto_back_and_forth && active_ws | 575 | if (config->auto_back_and_forth && active_ws && |
576 | && active_ws == workspace && seat->prev_workspace_name) { | 576 | active_ws == workspace && seat->prev_workspace_name) { |
577 | struct sway_workspace *new_ws = | 577 | struct sway_workspace *new_ws = |
578 | workspace_by_name(seat->prev_workspace_name); | 578 | workspace_by_name(seat->prev_workspace_name); |
579 | workspace = new_ws ? | 579 | workspace = new_ws ? new_ws |
580 | new_ws : | 580 | : workspace_create(NULL, seat->prev_workspace_name); |
581 | workspace_create(NULL, seat->prev_workspace_name); | ||
582 | } | 581 | } |
582 | return workspace; | ||
583 | } | ||
584 | |||
585 | bool workspace_switch(struct sway_workspace *workspace) { | ||
586 | struct sway_seat *seat = input_manager_current_seat(); | ||
583 | 587 | ||
584 | sway_log(SWAY_DEBUG, "Switching to workspace %p:%s", | 588 | sway_log(SWAY_DEBUG, "Switching to workspace %p:%s", |
585 | workspace, workspace->name); | 589 | workspace, workspace->name); |