diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-11 11:22:38 -0500 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-11-11 11:22:38 -0500 |
commit | 12876932a948d7265745efaccafea509bdbaffe8 (patch) | |
tree | 458a3acb6db39a78d26b4ce38ea637aa21812e29 /sway/commands | |
parent | 80a1c340a9c8c8aac5fe4dd7bc1dc15b43fce0dc (diff) |
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')
-rw-r--r-- | sway/commands/workspace.c | 13 |
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) { return NULL; } wsc->workspace = strdup(ws_name); + wsc->outputs = create_list(); wsc->gaps_inner = INT_MIN; wsc->gaps_outer.top = INT_MIN; wsc->gaps_outer.right = INT_MIN; @@ -32,7 +33,7 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) { void free_workspace_config(struct workspace_config *wsc) { free(wsc->workspace); - free(wsc->output); + free_flat_list(wsc->outputs); free(wsc); } @@ -141,18 +142,20 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { } } if (output_location >= 0) { - if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) { + if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, + output_location + 2))) { return error; } - char *ws_name = join_args(argv, argc - 2); + char *ws_name = join_args(argv, output_location); struct workspace_config *wsc = workspace_config_find_or_create(ws_name); free(ws_name); if (!wsc) { return cmd_results_new(CMD_FAILURE, "workspace output", "Unable to allocate workspace output"); } - free(wsc->output); - wsc->output = strdup(argv[output_location + 1]); + for (int i = output_location + 1; i < argc; ++i) { + list_add(wsc->outputs, strdup(argv[i])); + } } else if (gaps_location >= 0) { if ((error = cmd_workspace_gaps(argc, argv, gaps_location))) { return error; |