aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/workspace.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-11 11:22:38 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-11 11:22:38 -0500
commit12876932a948d7265745efaccafea509bdbaffe8 (patch)
tree458a3acb6db39a78d26b4ce38ea637aa21812e29 /sway/commands/workspace.c
parentMerge pull request #3098 from c-edw/feature/RefactorArgParse (diff)
downloadsway-12876932a948d7265745efaccafea509bdbaffe8.tar.gz
sway-12876932a948d7265745efaccafea509bdbaffe8.tar.zst
sway-12876932a948d7265745efaccafea509bdbaffe8.zip
Allow multiple outputs for workspace output
`i3 4.16` allows users to list multiple outputs for a workspace and the first available will be used. The syntax is as follows: `workspace <workspace> output <outputs...>` Additionally when the workspace is created, the outputs get added to the output priority list in the order specified. This ensures that if a higher output gets connected, the workspace will move to the higher output. This works the same way as if the user had a workspace on an output, disconnected the output, and then later reconnected the output.
Diffstat (limited to 'sway/commands/workspace.c')
-rw-r--r--sway/commands/workspace.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c
index 168494d2..92118ecf 100644
--- a/sway/commands/workspace.c
+++ b/sway/commands/workspace.c
@@ -21,6 +21,7 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
21 return NULL; 21 return NULL;
22 } 22 }
23 wsc->workspace = strdup(ws_name); 23 wsc->workspace = strdup(ws_name);
24 wsc->outputs = create_list();
24 wsc->gaps_inner = INT_MIN; 25 wsc->gaps_inner = INT_MIN;
25 wsc->gaps_outer.top = INT_MIN; 26 wsc->gaps_outer.top = INT_MIN;
26 wsc->gaps_outer.right = INT_MIN; 27 wsc->gaps_outer.right = INT_MIN;
@@ -32,7 +33,7 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) {
32 33
33void free_workspace_config(struct workspace_config *wsc) { 34void free_workspace_config(struct workspace_config *wsc) {
34 free(wsc->workspace); 35 free(wsc->workspace);
35 free(wsc->output); 36 free_flat_list(wsc->outputs);
36 free(wsc); 37 free(wsc);
37} 38}
38 39
@@ -141,18 +142,20 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
141 } 142 }
142 } 143 }
143 if (output_location >= 0) { 144 if (output_location >= 0) {
144 if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) { 145 if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST,
146 output_location + 2))) {
145 return error; 147 return error;
146 } 148 }
147 char *ws_name = join_args(argv, argc - 2); 149 char *ws_name = join_args(argv, output_location);
148 struct workspace_config *wsc = workspace_config_find_or_create(ws_name); 150 struct workspace_config *wsc = workspace_config_find_or_create(ws_name);
149 free(ws_name); 151 free(ws_name);
150 if (!wsc) { 152 if (!wsc) {
151 return cmd_results_new(CMD_FAILURE, "workspace output", 153 return cmd_results_new(CMD_FAILURE, "workspace output",
152 "Unable to allocate workspace output"); 154 "Unable to allocate workspace output");
153 } 155 }
154 free(wsc->output); 156 for (int i = output_location + 1; i < argc; ++i) {
155 wsc->output = strdup(argv[output_location + 1]); 157 list_add(wsc->outputs, strdup(argv[i]));
158 }
156 } else if (gaps_location >= 0) { 159 } else if (gaps_location >= 0) {
157 if ((error = cmd_workspace_gaps(argc, argv, gaps_location))) { 160 if ((error = cmd_workspace_gaps(argc, argv, gaps_location))) {
158 return error; 161 return error;