From aaae59026ff3751190b93277ac6d7566e373c892 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 12:36:06 +0100 Subject: Add output config --- sway/commands/output.c | 253 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 sway/commands/output.c (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c new file mode 100644 index 00000000..c964bef7 --- /dev/null +++ b/sway/commands/output.c @@ -0,0 +1,253 @@ +#define _XOPEN_SOURCE 500 +#include +#include +#include +#include +#include +#include +#include +#include "sway/commands.h" +#include "sway/config.h" +#include "list.h" +#include "log.h" +#include "stringop.h" + +static char *bg_options[] = { + "stretch", + "center", + "fill", + "fit", + "tile", +}; + +struct cmd_results *cmd_output(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "output", EXPECTED_AT_LEAST, 1))) { + return error; + } + const char *name = argv[0]; + + struct output_config *output = calloc(1, sizeof(struct output_config)); + if (!output) { + return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config"); + } + output->x = output->y = output->width = output->height = -1; + output->name = strdup(name); + output->enabled = -1; + output->scale = 1; + + // TODO: atoi doesn't handle invalid numbers + + int i; + for (i = 1; i < argc; ++i) { + const char *command = argv[i]; + + if (strcasecmp(command, "disable") == 0) { + output->enabled = 0; + } else if (strcasecmp(command, "resolution") == 0 || strcasecmp(command, "res") == 0) { + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing resolution argument."); + goto fail; + } + char *res = argv[i]; + char *x = strchr(res, 'x'); + int width = -1, height = -1; + if (x != NULL) { + // Format is 1234x4321 + *x = '\0'; + width = atoi(res); + height = atoi(x + 1); + *x = 'x'; + } else { + // Format is 1234 4321 + width = atoi(res); + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing resolution argument (height)."); + goto fail; + } + res = argv[i]; + height = atoi(res); + } + output->width = width; + output->height = height; + } else if (strcasecmp(command, "refresh_rate") == 0) { + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing refresh_rate argument."); + goto fail; + } + output->refresh_rate = atof(argv[i]); + } else if (strcasecmp(command, "position") == 0 || strcasecmp(command, "pos") == 0) { + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing position argument."); + goto fail; + } + char *res = argv[i]; + char *c = strchr(res, ','); + int x = -1, y = -1; + if (c != NULL) { + // Format is 1234,4321 + *c = '\0'; + x = atoi(res); + y = atoi(c + 1); + *c = ','; + } else { + // Format is 1234 4321 + x = atoi(res); + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing position argument (y)."); + goto fail; + } + res = argv[i]; + y = atoi(res); + } + output->x = x; + output->y = y; + } else if (strcasecmp(command, "scale") == 0) { + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing scale parameter."); + goto fail; + } + output->scale = atoi(argv[i]); + } else if (strcasecmp(command, "transform") == 0) { + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing transform parameter."); + goto fail; + } + char *value = argv[i]; + if (strcmp(value, "normal") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_NORMAL; + } else if (strcmp(value, "90") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_90; + } else if (strcmp(value, "180") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_180; + } else if (strcmp(value, "270") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_270; + } else if (strcmp(value, "flipped") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_FLIPPED; + } else if (strcmp(value, "flipped-90") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_90; + } else if (strcmp(value, "flipped-180") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_180; + } else if (strcmp(value, "flipped-270") == 0) { + output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; + } else { + error = cmd_results_new(CMD_INVALID, "output", "Invalid output transform."); + goto fail; + } + } else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) { + wordexp_t p; + if (++i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing background file or color specification."); + goto fail; + } + if (i + 1 >= argc) { + error = cmd_results_new(CMD_INVALID, "output", "Missing background scaling mode or `solid_color`."); + goto fail; + } + if (strcasecmp(argv[i + 1], "solid_color") == 0) { + output->background = strdup(argv[argc - 2]); + output->background_option = strdup("solid_color"); + } else { + // argv[i+j]=bg_option + bool valid = false; + char *mode; + size_t j; + for (j = 0; j < (size_t) (argc - i); ++j) { + mode = argv[i + j]; + for (size_t k = 0; k < sizeof(bg_options) / sizeof(char *); ++k) { + if (strcasecmp(mode, bg_options[k]) == 0) { + valid = true; + break; + } + } + if (valid) { + break; + } + } + if (!valid) { + error = cmd_results_new(CMD_INVALID, "output", "Missing background scaling mode."); + goto fail; + } + + char *src = join_args(argv + i, j); + if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { + error = cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src); + goto fail; + } + free(src); + src = p.we_wordv[0]; + if (config->reading && *src != '/') { + char *conf = strdup(config->current_config); + if (conf) { + char *conf_path = dirname(conf); + src = malloc(strlen(conf_path) + strlen(src) + 2); + if (src) { + sprintf(src, "%s/%s", conf_path, p.we_wordv[0]); + } else { + sway_log(L_ERROR, "Unable to allocate background source"); + } + free(conf); + } else { + sway_log(L_ERROR, "Unable to allocate background source"); + } + } + if (!src || access(src, F_OK) == -1) { + error = cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src); + wordfree(&p); + goto fail; + } + + output->background = strdup(src); + output->background_option = strdup(mode); + if (src != p.we_wordv[0]) { + free(src); + } + wordfree(&p); + + i += j; + } + } + } + + i = list_seq_find(config->output_configs, output_name_cmp, name); + if (i >= 0) { + // merge existing config + struct output_config *oc = config->output_configs->items[i]; + merge_output_config(oc, output); + free_output_config(output); + output = oc; + } else { + list_add(config->output_configs, output); + } + + sway_log(L_DEBUG, "Config stored for output %s (enabled:%d) (%d x %d @ " + "%d, %d scale %d transform %d refresh_rate %f) (bg %s %s)", + output->name, output->enabled, output->width, + output->height, output->x, output->y, output->scale, + output->transform, output->refresh_rate, + 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 wlc. + 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); + + if (strcmp(output->name, "*") != 0) { + // stop looking if the output config isn't applicable to all outputs + break; + } + } + } + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); + +fail: + free_output_config(output); + return error; +} -- cgit v1.2.3 From 68ae989ceef0a144988c0a55b13aaacf514b957d Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 12:57:13 +0100 Subject: Init, merge output config params, use wlr_output_layout --- sway/commands/output.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index c964bef7..bbf8efc3 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -31,10 +31,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { if (!output) { return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config"); } - output->x = output->y = output->width = output->height = -1; + output_config_defaults(output); output->name = strdup(name); - output->enabled = -1; - output->scale = 1; // TODO: atoi doesn't handle invalid numbers -- cgit v1.2.3 From 8764dc26c634379ca5b5c2c4fc26cf8be9adf027 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 6 Dec 2017 19:45:43 +0100 Subject: Add new_output_config, update root container size on output hotplug --- sway/commands/output.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index bbf8efc3..11da0ff6 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -27,11 +27,10 @@ struct cmd_results *cmd_output(int argc, char **argv) { } const char *name = argv[0]; - struct output_config *output = calloc(1, sizeof(struct output_config)); + struct output_config *output = new_output_config(); if (!output) { return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config"); } - output_config_defaults(output); output->name = strdup(name); // TODO: atoi doesn't handle invalid numbers -- cgit v1.2.3 From 4a14aa9ad99a6f316024e110332a0b482e231543 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 9 Dec 2017 15:48:52 +0100 Subject: Remove output from layout --- sway/commands/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index 11da0ff6..be78358a 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -227,7 +227,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { 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 wlc. + // 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]; -- cgit v1.2.3 From d293c429424a9f96c3fc8143af457645326e7a0e Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 12 Dec 2017 21:09:51 +0100 Subject: Update output container box in event handler --- sway/commands/output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index be78358a..23792855 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -29,7 +29,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { struct output_config *output = new_output_config(); if (!output) { - return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config"); + sway_log(L_ERROR, "Failed to allocate output config"); + return NULL; } output->name = strdup(name); -- cgit v1.2.3 From 4d389f8b6523af741761009effd4d6dd79156afe Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 14 Dec 2017 00:45:47 +0100 Subject: Replace refresh_rate and position by mode in output command --- sway/commands/output.c | 85 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 31 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index 23792855..daaacad7 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -42,61 +42,84 @@ struct cmd_results *cmd_output(int argc, char **argv) { if (strcasecmp(command, "disable") == 0) { output->enabled = 0; - } else if (strcasecmp(command, "resolution") == 0 || strcasecmp(command, "res") == 0) { + } else if (strcasecmp(command, "mode") == 0 || + strcasecmp(command, "resolution") == 0 || + strcasecmp(command, "res") == 0) { if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing resolution argument."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing mode argument."); goto fail; } - char *res = argv[i]; - char *x = strchr(res, 'x'); + int width = -1, height = -1; - if (x != NULL) { + float refresh_rate = -1; + + char *end; + width = strtol(argv[i], &end, 10); + if (*end) { // Format is 1234x4321 - *x = '\0'; - width = atoi(res); - height = atoi(x + 1); - *x = 'x'; + if (*end != 'x') { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid mode width."); + goto fail; + } + ++end; + height = strtol(end, &end, 10); + if (*end) { + if (*end != '@') { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid mode height."); + goto fail; + } + ++end; + refresh_rate = strtof(end, &end); + if (strcasecmp("Hz", end) != 0) { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid mode refresh rate."); + goto fail; + } + } } else { - // Format is 1234 4321 - width = atoi(res); - if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing resolution argument (height)."); + // Format is 1234 4321 (legacy) + ++i; + if (i >= argc) { + error = cmd_results_new(CMD_INVALID, "output", + "Missing mode argument (height)."); + goto fail; + } + height = strtol(argv[i], &end, 10); + if (*end) { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid mode height."); goto fail; } - res = argv[i]; - height = atoi(res); } output->width = width; output->height = height; - } else if (strcasecmp(command, "refresh_rate") == 0) { - if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing refresh_rate argument."); - goto fail; - } - output->refresh_rate = atof(argv[i]); + output->refresh_rate = refresh_rate; } else if (strcasecmp(command, "position") == 0 || strcasecmp(command, "pos") == 0) { if (++i >= argc) { error = cmd_results_new(CMD_INVALID, "output", "Missing position argument."); goto fail; } - char *res = argv[i]; - char *c = strchr(res, ','); + char *pos = argv[i]; + char *c = strchr(pos, ','); int x = -1, y = -1; if (c != NULL) { // Format is 1234,4321 *c = '\0'; - x = atoi(res); + x = atoi(pos); y = atoi(c + 1); *c = ','; } else { // Format is 1234 4321 - x = atoi(res); + x = atoi(pos); if (++i >= argc) { error = cmd_results_new(CMD_INVALID, "output", "Missing position argument (y)."); goto fail; } - res = argv[i]; - y = atoi(res); + pos = argv[i]; + y = atoi(pos); } output->x = x; output->y = y; @@ -218,11 +241,11 @@ struct cmd_results *cmd_output(int argc, char **argv) { list_add(config->output_configs, output); } - sway_log(L_DEBUG, "Config stored for output %s (enabled:%d) (%d x %d @ " - "%d, %d scale %d transform %d refresh_rate %f) (bg %s %s)", + sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " + "position %d,%d scale %d transform %d) (bg %s %s)", output->name, output->enabled, output->width, - output->height, output->x, output->y, output->scale, - output->transform, output->refresh_rate, + output->height, output->refresh_rate, output->x, output->y, + output->scale, output->transform, output->background, output->background_option); if (output->name) { -- cgit v1.2.3 From 9254c5a93f1a38612d5391e34e4fe3b6c9e433a7 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 14 Dec 2017 00:50:01 +0100 Subject: Fail if unknown output subcommand --- sway/commands/output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index daaacad7..16b711f1 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -192,7 +192,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { char *src = join_args(argv + i, j); if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { - error = cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src); + error = cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s).", src); goto fail; } free(src); @@ -213,7 +213,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { } } if (!src || access(src, F_OK) == -1) { - error = cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src); + error = cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s).", src); wordfree(&p); goto fail; } @@ -227,6 +227,9 @@ struct cmd_results *cmd_output(int argc, char **argv) { i += j; } + } else { + error = cmd_results_new(CMD_INVALID, "output", "Invalid output subcommand: %s.", command); + goto fail; } } -- cgit v1.2.3 From cba592b3d2c516cab9f4e8325037dfdf6e30cb9a Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 14 Dec 2017 02:23:33 +0100 Subject: Use strtol instead of atoi in output command --- sway/commands/output.c | 114 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 40 deletions(-) (limited to 'sway/commands') diff --git a/sway/commands/output.c b/sway/commands/output.c index 16b711f1..d71e4d8d 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -34,8 +34,6 @@ struct cmd_results *cmd_output(int argc, char **argv) { } output->name = strdup(name); - // TODO: atoi doesn't handle invalid numbers - int i; for (i = 1; i < argc; ++i) { const char *command = argv[i]; @@ -80,9 +78,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { } } } else { - // Format is 1234 4321 (legacy) - ++i; - if (i >= argc) { + // Format is 1234 4321 + if (++i >= argc) { error = cmd_results_new(CMD_INVALID, "output", "Missing mode argument (height)."); goto fail; @@ -97,41 +94,66 @@ struct cmd_results *cmd_output(int argc, char **argv) { output->width = width; output->height = height; output->refresh_rate = refresh_rate; - } else if (strcasecmp(command, "position") == 0 || strcasecmp(command, "pos") == 0) { + } else if (strcasecmp(command, "position") == 0 || + strcasecmp(command, "pos") == 0) { if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing position argument."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing position argument."); goto fail; } - char *pos = argv[i]; - char *c = strchr(pos, ','); + int x = -1, y = -1; - if (c != NULL) { + + char *end; + x = strtol(argv[i], &end, 10); + if (*end) { // Format is 1234,4321 - *c = '\0'; - x = atoi(pos); - y = atoi(c + 1); - *c = ','; + if (*end != ',') { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid position x."); + goto fail; + } + ++end; + y = strtol(end, &end, 10); + if (*end) { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid position y."); + goto fail; + } } else { - // Format is 1234 4321 - x = atoi(pos); + // Format is 1234 4321 (legacy) if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing position argument (y)."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing position argument (y)."); + goto fail; + } + y = strtol(argv[i], &end, 10); + if (*end) { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid position y."); goto fail; } - pos = argv[i]; - y = atoi(pos); } + output->x = x; output->y = y; } else if (strcasecmp(command, "scale") == 0) { if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing scale parameter."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing scale parameter."); + goto fail; + } + char *end; + output->scale = strtol(argv[i], &end, 10); + if (*end) { + error = cmd_results_new(CMD_INVALID, "output", + "Invalid scale."); goto fail; } - output->scale = atoi(argv[i]); } else if (strcasecmp(command, "transform") == 0) { if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing transform parameter."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing transform parameter."); goto fail; } char *value = argv[i]; @@ -152,17 +174,21 @@ struct cmd_results *cmd_output(int argc, char **argv) { } else if (strcmp(value, "flipped-270") == 0) { output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; } else { - error = cmd_results_new(CMD_INVALID, "output", "Invalid output transform."); + error = cmd_results_new(CMD_INVALID, "output", + "Invalid output transform."); goto fail; } - } else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) { + } else if (strcasecmp(command, "background") == 0 || + strcasecmp(command, "bg") == 0) { wordexp_t p; if (++i >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing background file or color specification."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing background file or color specification."); goto fail; } if (i + 1 >= argc) { - error = cmd_results_new(CMD_INVALID, "output", "Missing background scaling mode or `solid_color`."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing background scaling mode or `solid_color`."); goto fail; } if (strcasecmp(argv[i + 1], "solid_color") == 0) { @@ -175,7 +201,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { size_t j; for (j = 0; j < (size_t) (argc - i); ++j) { mode = argv[i + j]; - for (size_t k = 0; k < sizeof(bg_options) / sizeof(char *); ++k) { + size_t n = sizeof(bg_options) / sizeof(char *); + for (size_t k = 0; k < n; ++k) { if (strcasecmp(mode, bg_options[k]) == 0) { valid = true; break; @@ -186,13 +213,15 @@ struct cmd_results *cmd_output(int argc, char **argv) { } } if (!valid) { - error = cmd_results_new(CMD_INVALID, "output", "Missing background scaling mode."); + error = cmd_results_new(CMD_INVALID, "output", + "Missing background scaling mode."); goto fail; } char *src = join_args(argv + i, j); if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) { - error = cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s).", src); + error = cmd_results_new(CMD_INVALID, "output", + "Invalid syntax (%s).", src); goto fail; } free(src); @@ -205,15 +234,18 @@ struct cmd_results *cmd_output(int argc, char **argv) { if (src) { sprintf(src, "%s/%s", conf_path, p.we_wordv[0]); } else { - sway_log(L_ERROR, "Unable to allocate background source"); + sway_log(L_ERROR, + "Unable to allocate background source"); } free(conf); } else { - sway_log(L_ERROR, "Unable to allocate background source"); + sway_log(L_ERROR, + "Unable to allocate background source"); } } if (!src || access(src, F_OK) == -1) { - error = cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s).", src); + error = cmd_results_new(CMD_INVALID, "output", + "Background file unreadable (%s).", src); wordfree(&p); goto fail; } @@ -228,7 +260,8 @@ struct cmd_results *cmd_output(int argc, char **argv) { i += j; } } else { - error = cmd_results_new(CMD_INVALID, "output", "Invalid output subcommand: %s.", command); + error = cmd_results_new(CMD_INVALID, "output", + "Invalid output subcommand: %s.", command); goto fail; } } @@ -245,11 +278,10 @@ struct cmd_results *cmd_output(int argc, char **argv) { } sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " - "position %d,%d scale %d transform %d) (bg %s %s)", - output->name, output->enabled, output->width, - output->height, output->refresh_rate, output->x, output->y, - output->scale, output->transform, - output->background, output->background_option); + "position %d,%d scale %d transform %d) (bg %s %s)", + output->name, output->enabled, output->width, output->height, + 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 @@ -258,11 +290,13 @@ struct cmd_results *cmd_output(int argc, char **argv) { 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))) { + if (cont->name && ((strcmp(cont->name, output->name) == 0) || + (strcmp(output->name, "*") == 0))) { apply_output_config(output, cont); if (strcmp(output->name, "*") != 0) { - // stop looking if the output config isn't applicable to all outputs + // Stop looking if the output config isn't applicable to all + // outputs break; } } -- cgit v1.2.3