aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-04-29 10:04:13 -0400
committerDrew DeVault <sir@cmpwn.com>2017-05-01 10:25:09 -0400
commit86f81e03644bd404176ea4a2dce7534d4c58130e (patch)
tree3dbb0e096773fdb128273ea0cfadc9843fdf7b35
parentaa341ebe7bfc1afce30bd685a25523bd96f71e09 (diff)
downloadsway-86f81e03644bd404176ea4a2dce7534d4c58130e.zip
sway-86f81e03644bd404176ea4a2dce7534d4c58130e.tar.gz
sway-86f81e03644bd404176ea4a2dce7534d4c58130e.tar.bz2
Merge pull request #1201 from SirCmpwn/fix-colors
Support specifying fewer than 5 colors
-rw-r--r--sway/commands.c2
-rw-r--r--sway/commands/client.c22
2 files changed, 12 insertions, 12 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 4d7af30..d2f6b88 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -249,7 +249,7 @@ static struct cmd_handler bar_handlers[] = {
*/
struct cmd_results *add_color(const char *name, char *buffer, const char *color) {
int len = strlen(color);
- if (len != 7 && len != 9 ) {
+ if (len != 7 && len != 9) {
return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color);
}
diff --git a/sway/commands/client.c b/sway/commands/client.c
index 7954f67..30f9137 100644
--- a/sway/commands/client.c
+++ b/sway/commands/client.c
@@ -4,27 +4,27 @@
static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) {
struct cmd_results *error = NULL;
- if (argc != 5) {
- return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly five color values");
+ if (argc < 3 || argc > 5) {
+ return cmd_results_new(CMD_INVALID, cmd_name, "Requires between three and five color values");
}
- uint32_t colors[5];
+ uint32_t *colors[5] = {
+ &border_colors->border,
+ &border_colors->background,
+ &border_colors->text,
+ &border_colors->indicator,
+ &border_colors->child_border
+ };
int i;
- for (i = 0; i < 5; i++) {
+ for (i = 0; i < argc; i++) {
char buffer[10];
error = add_color(cmd_name, buffer, argv[i]);
if (error) {
return error;
}
- colors[i] = strtoul(buffer+1, NULL, 16);
+ *colors[i] = strtoul(buffer + 1, NULL, 16);
}
- border_colors->border = colors[0];
- border_colors->background = colors[1];
- border_colors->text = colors[2];
- border_colors->indicator = colors[3];
- border_colors->child_border = colors[4];
-
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}