diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-10-21 11:26:22 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-10-21 11:26:22 +1000 |
commit | c5a6c37275978ddc8c221ca73ae1a39254dd68f5 (patch) | |
tree | 2255d845647357cdbe6fdfcb1c6a40210a69ddb7 /sway/commands | |
parent | Merge pull request #2901 from ianyfan/swaybar (diff) | |
download | sway-c5a6c37275978ddc8c221ca73ae1a39254dd68f5.tar.gz sway-c5a6c37275978ddc8c221ca73ae1a39254dd68f5.tar.zst sway-c5a6c37275978ddc8c221ca73ae1a39254dd68f5.zip |
Make workspace back_and_forth seat-specific
* When using multiple seats, each seat has its own prev_workspace_name
for the purpose of workspace back_and_forth.
* Removes prev_workspace_name global variable.
* Removes unused next_name_map function in tree/workspace.c.
* Fixes memory leak in seat_destroy (seat was not freed).
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/move.c | 8 | ||||
-rw-r--r-- | sway/commands/swap.c | 8 | ||||
-rw-r--r-- | sway/commands/workspace.c | 5 |
3 files changed, 11 insertions, 10 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 941b284a..a5b7f661 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -429,8 +429,8 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { | |||
429 | ws = workspace_by_name(argv[2]); | 429 | ws = workspace_by_name(argv[2]); |
430 | } else if (strcasecmp(argv[2], "back_and_forth") == 0) { | 430 | } else if (strcasecmp(argv[2], "back_and_forth") == 0) { |
431 | if (!(ws = workspace_by_name(argv[2]))) { | 431 | if (!(ws = workspace_by_name(argv[2]))) { |
432 | if (prev_workspace_name) { | 432 | if (seat->prev_workspace_name) { |
433 | ws_name = strdup(prev_workspace_name); | 433 | ws_name = strdup(seat->prev_workspace_name); |
434 | } else { | 434 | } else { |
435 | return cmd_results_new(CMD_FAILURE, "move", | 435 | return cmd_results_new(CMD_FAILURE, "move", |
436 | "No workspace was previously active."); | 436 | "No workspace was previously active."); |
@@ -455,13 +455,13 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) { | |||
455 | } | 455 | } |
456 | 456 | ||
457 | if (!no_auto_back_and_forth && config->auto_back_and_forth && | 457 | if (!no_auto_back_and_forth && config->auto_back_and_forth && |
458 | prev_workspace_name) { | 458 | seat->prev_workspace_name) { |
459 | // auto back and forth move | 459 | // auto back and forth move |
460 | if (old_ws && old_ws->name && | 460 | if (old_ws && old_ws->name && |
461 | strcmp(old_ws->name, ws_name) == 0) { | 461 | strcmp(old_ws->name, ws_name) == 0) { |
462 | // if target workspace is the current one | 462 | // if target workspace is the current one |
463 | free(ws_name); | 463 | free(ws_name); |
464 | ws_name = strdup(prev_workspace_name); | 464 | ws_name = strdup(seat->prev_workspace_name); |
465 | ws = workspace_by_name(ws_name); | 465 | ws = workspace_by_name(ws_name); |
466 | } | 466 | } |
467 | } | 467 | } |
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index 6062724d..afe11a47 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -116,8 +116,8 @@ static void container_swap(struct sway_container *con1, | |||
116 | output_get_active_workspace(con2->workspace->output); | 116 | output_get_active_workspace(con2->workspace->output); |
117 | 117 | ||
118 | char *stored_prev_name = NULL; | 118 | char *stored_prev_name = NULL; |
119 | if (prev_workspace_name) { | 119 | if (seat->prev_workspace_name) { |
120 | stored_prev_name = strdup(prev_workspace_name); | 120 | stored_prev_name = strdup(seat->prev_workspace_name); |
121 | } | 121 | } |
122 | 122 | ||
123 | swap_places(con1, con2); | 123 | swap_places(con1, con2); |
@@ -132,8 +132,8 @@ static void container_swap(struct sway_container *con1, | |||
132 | swap_focus(con1, con2, seat, focus); | 132 | swap_focus(con1, con2, seat, focus); |
133 | 133 | ||
134 | if (stored_prev_name) { | 134 | if (stored_prev_name) { |
135 | free(prev_workspace_name); | 135 | free(seat->prev_workspace_name); |
136 | prev_workspace_name = stored_prev_name; | 136 | seat->prev_workspace_name = stored_prev_name; |
137 | } | 137 | } |
138 | 138 | ||
139 | if (fs1) { | 139 | if (fs1) { |
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index da597f8a..745b40c7 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -142,12 +142,13 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
142 | strcasecmp(argv[0], "current") == 0) { | 142 | strcasecmp(argv[0], "current") == 0) { |
143 | ws = workspace_by_name(argv[0]); | 143 | ws = workspace_by_name(argv[0]); |
144 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { | 144 | } else if (strcasecmp(argv[0], "back_and_forth") == 0) { |
145 | if (!prev_workspace_name) { | 145 | struct sway_seat *seat = config->handler_context.seat; |
146 | if (!seat->prev_workspace_name) { | ||
146 | return cmd_results_new(CMD_INVALID, "workspace", | 147 | return cmd_results_new(CMD_INVALID, "workspace", |
147 | "There is no previous workspace"); | 148 | "There is no previous workspace"); |
148 | } | 149 | } |
149 | if (!(ws = workspace_by_name(argv[0]))) { | 150 | if (!(ws = workspace_by_name(argv[0]))) { |
150 | ws = workspace_create(NULL, prev_workspace_name); | 151 | ws = workspace_create(NULL, seat->prev_workspace_name); |
151 | } | 152 | } |
152 | } else { | 153 | } else { |
153 | char *name = join_args(argv, argc); | 154 | char *name = join_args(argv, argc); |