aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-01-04 09:47:04 -0500
committerGitHub <noreply@github.com>2018-01-04 09:47:04 -0500
commitbc7011db3c9298a6cdc9ab622c18450ba184973a (patch)
tree4e3260f1a88cc13d39115e22afba6c2b8b4a2d8f /sway/commands
parent0f42f8c15889acd21c52ca4b138fad3e5ed4e64b (diff)
parentead3f1e676923b0457cef77b0b482e76cac50307 (diff)
Merge pull request #1543 from emersion/output-config-by-identifier
Allow to configure outputs by their identifier
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/output.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 8cc74bcc..8c0fa63c 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -231,8 +231,8 @@ static struct cmd_results *cmd_output_background(struct output_config *output,
}
struct cmd_results *cmd_output(int argc, char **argv) {
- struct cmd_results *error = NULL;
- if ((error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1))) {
+ struct cmd_results *error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1);
+ if (error != NULL) {
return error;
}
@@ -275,11 +275,11 @@ struct cmd_results *cmd_output(int argc, char **argv) {
int i = list_seq_find(config->output_configs, output_name_cmp, output->name);
if (i >= 0) {
- // merge existing config
- struct output_config *oc = config->output_configs->items[i];
- merge_output_config(oc, output);
+ // Merge existing config
+ struct output_config *current = config->output_configs->items[i];
+ merge_output_config(current, output);
free_output_config(output);
- output = oc;
+ output = current;
} else {
list_add(config->output_configs, output);
}
@@ -290,22 +290,26 @@ struct cmd_results *cmd_output(int argc, char **argv) {
output->refresh_rate, output->x, output->y, output->scale,
output->transform, output->background, output->background_option);
- if (output->name) {
- // Try to find the output container and apply configuration now. If
- // this is during startup then there will be no container and config
- // will be applied during normal "new output" event from wlroots.
- swayc_t *cont = NULL;
- for (int i = 0; i < root_container.children->length; ++i) {
- cont = root_container.children->items[i];
- if (cont->name && ((strcmp(cont->name, output->name) == 0) ||
- (strcmp(output->name, "*") == 0))) {
- apply_output_config(output, cont);
+ // Try to find the output container and apply configuration now. If
+ // this is during startup then there will be no container and config
+ // will be applied during normal "new output" event from wlroots.
+ char identifier[128];
+ bool all = strcmp(output->name, "*") == 0;
+ for (int i = 0; i < root_container.children->length; ++i) {
+ swayc_t *cont = root_container.children->items[i];
+ if (cont->type != C_OUTPUT) {
+ continue;
+ }
- if (strcmp(output->name, "*") != 0) {
- // Stop looking if the output config isn't applicable to all
- // outputs
- break;
- }
+ output_get_identifier(identifier, sizeof(identifier), cont->sway_output);
+ if (all || strcmp(cont->name, output->name) == 0 ||
+ strcmp(identifier, output->name) == 0) {
+ apply_output_config(output, cont);
+
+ if (!all) {
+ // Stop looking if the output config isn't applicable to all
+ // outputs
+ break;
}
}
}