aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorRagnar Groot Koerkamp <ragnar.grootkoerkamp@gmail.com>2021-06-18 12:19:18 +0200
committerSimon Ser <contact@emersion.fr>2021-06-18 16:15:02 +0200
commit3080f1b9ce069c0697291bd3ef23c38ae610fa8c (patch)
treef4312e265dd00d30be76af4b39e2daeeb9f944e5 /sway/tree/workspace.c
parent771cff23fb70873dbf5a5690f0bc20e545d1b839 (diff)
Move auto_back_and_forth logic out of workspace_switch
This extracts the code to a separate workspace_auto_back_and_forth function. It also removes the bool argument by adding an extra if statement at the call site, and repurposes the no_auto_back_and_forth variable to auto_back_and_forth for simpler understanding.
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c20
1 files changed, 12 insertions, 8 deletions
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(
return workspace_output_prev_next_impl(current->output, -1, create);
}
-bool workspace_switch(struct sway_workspace *workspace,
- bool no_auto_back_and_forth) {
+struct sway_workspace *workspace_auto_back_and_forth(
+ struct sway_workspace *workspace) {
struct sway_seat *seat = input_manager_current_seat();
struct sway_workspace *active_ws = NULL;
struct sway_node *focus = seat_get_focus_inactive(seat, &root->node);
@@ -572,14 +572,18 @@ bool workspace_switch(struct sway_workspace *workspace,
active_ws = focus->sway_container->pending.workspace;
}
- if (!no_auto_back_and_forth && config->auto_back_and_forth && active_ws
- && active_ws == workspace && seat->prev_workspace_name) {
+ if (config->auto_back_and_forth && active_ws &&
+ active_ws == workspace && seat->prev_workspace_name) {
struct sway_workspace *new_ws =
- workspace_by_name(seat->prev_workspace_name);
- workspace = new_ws ?
- new_ws :
- workspace_create(NULL, seat->prev_workspace_name);
+ workspace_by_name(seat->prev_workspace_name);
+ workspace = new_ws ? new_ws
+ : workspace_create(NULL, seat->prev_workspace_name);
}
+ return workspace;
+}
+
+bool workspace_switch(struct sway_workspace *workspace) {
+ struct sway_seat *seat = input_manager_current_seat();
sway_log(SWAY_DEBUG, "Switching to workspace %p:%s",
workspace, workspace->name);