aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/output.c
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2017-12-29 19:04:16 +0100
committerLibravatar emersion <contact@emersion.fr>2017-12-29 19:04:16 +0100
commitead3f1e676923b0457cef77b0b482e76cac50307 (patch)
tree6a4c75b23de360d4eadbf4e1aa647a0d93c81eb2 /sway/commands/output.c
parentMerge pull request #1542 from emersion/swaymsg-output (diff)
downloadsway-ead3f1e676923b0457cef77b0b482e76cac50307.tar.gz
sway-ead3f1e676923b0457cef77b0b482e76cac50307.tar.zst
sway-ead3f1e676923b0457cef77b0b482e76cac50307.zip
Allow to configure outputs by their identifier
Diffstat (limited to 'sway/commands/output.c')
-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,
231} 231}
232 232
233struct cmd_results *cmd_output(int argc, char **argv) { 233struct cmd_results *cmd_output(int argc, char **argv) {
234 struct cmd_results *error = NULL; 234 struct cmd_results *error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1);
235 if ((error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1))) { 235 if (error != NULL) {
236 return error; 236 return error;
237 } 237 }
238 238
@@ -275,11 +275,11 @@ struct cmd_results *cmd_output(int argc, char **argv) {
275 275
276 int i = list_seq_find(config->output_configs, output_name_cmp, output->name); 276 int i = list_seq_find(config->output_configs, output_name_cmp, output->name);
277 if (i >= 0) { 277 if (i >= 0) {
278 // merge existing config 278 // Merge existing config
279 struct output_config *oc = config->output_configs->items[i]; 279 struct output_config *current = config->output_configs->items[i];
280 merge_output_config(oc, output); 280 merge_output_config(current, output);
281 free_output_config(output); 281 free_output_config(output);
282 output = oc; 282 output = current;
283 } else { 283 } else {
284 list_add(config->output_configs, output); 284 list_add(config->output_configs, output);
285 } 285 }
@@ -290,22 +290,26 @@ struct cmd_results *cmd_output(int argc, char **argv) {
290 output->refresh_rate, output->x, output->y, output->scale, 290 output->refresh_rate, output->x, output->y, output->scale,
291 output->transform, output->background, output->background_option); 291 output->transform, output->background, output->background_option);
292 292
293 if (output->name) { 293 // Try to find the output container and apply configuration now. If
294 // Try to find the output container and apply configuration now. If 294 // this is during startup then there will be no container and config
295 // this is during startup then there will be no container and config 295 // will be applied during normal "new output" event from wlroots.
296 // will be applied during normal "new output" event from wlroots. 296 char identifier[128];
297 swayc_t *cont = NULL; 297 bool all = strcmp(output->name, "*") == 0;
298 for (int i = 0; i < root_container.children->length; ++i) { 298 for (int i = 0; i < root_container.children->length; ++i) {
299 cont = root_container.children->items[i]; 299 swayc_t *cont = root_container.children->items[i];
300 if (cont->name && ((strcmp(cont->name, output->name) == 0) || 300 if (cont->type != C_OUTPUT) {
301 (strcmp(output->name, "*") == 0))) { 301 continue;
302 apply_output_config(output, cont); 302 }
303 303
304 if (strcmp(output->name, "*") != 0) { 304 output_get_identifier(identifier, sizeof(identifier), cont->sway_output);
305 // Stop looking if the output config isn't applicable to all 305 if (all || strcmp(cont->name, output->name) == 0 ||
306 // outputs 306 strcmp(identifier, output->name) == 0) {
307 break; 307 apply_output_config(output, cont);
308 } 308
309 if (!all) {
310 // Stop looking if the output config isn't applicable to all
311 // outputs
312 break;
309 } 313 }
310 } 314 }
311 } 315 }