diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-04-29 09:56:07 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-04-29 09:56:07 -0400 |
commit | 02812a2e4da9f274c5957975fdbb4a4a58b20a69 (patch) | |
tree | 642c6451498e32eaa66b7f1b863b971d1688cb2c /sway | |
parent | Update .build.yml (diff) | |
download | sway-02812a2e4da9f274c5957975fdbb4a4a58b20a69.tar.gz sway-02812a2e4da9f274c5957975fdbb4a4a58b20a69.tar.zst sway-02812a2e4da9f274c5957975fdbb4a4a58b20a69.zip |
Support specifying fewer than 5 colors
This doesn't work, I'm not sure why. The color structs definitely get
changed but if you specify fewer than 5, it renders with the defaults.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/commands/client.c | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/sway/commands.c b/sway/commands.c index 01e5e6b5..509fd1a8 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -250,7 +250,7 @@ static struct cmd_handler bar_handlers[] = { | |||
250 | */ | 250 | */ |
251 | struct cmd_results *add_color(const char *name, char *buffer, const char *color) { | 251 | struct cmd_results *add_color(const char *name, char *buffer, const char *color) { |
252 | int len = strlen(color); | 252 | int len = strlen(color); |
253 | if (len != 7 && len != 9 ) { | 253 | if (len != 7 && len != 9) { |
254 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); | 254 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); |
255 | } | 255 | } |
256 | 256 | ||
diff --git a/sway/commands/client.c b/sway/commands/client.c index 7954f670..30f9137e 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c | |||
@@ -4,27 +4,27 @@ | |||
4 | 4 | ||
5 | static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) { | 5 | static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) { |
6 | struct cmd_results *error = NULL; | 6 | struct cmd_results *error = NULL; |
7 | if (argc != 5) { | 7 | if (argc < 3 || argc > 5) { |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly five color values"); | 8 | return cmd_results_new(CMD_INVALID, cmd_name, "Requires between three and five color values"); |
9 | } | 9 | } |
10 | 10 | ||
11 | uint32_t colors[5]; | 11 | uint32_t *colors[5] = { |
12 | &border_colors->border, | ||
13 | &border_colors->background, | ||
14 | &border_colors->text, | ||
15 | &border_colors->indicator, | ||
16 | &border_colors->child_border | ||
17 | }; | ||
12 | int i; | 18 | int i; |
13 | for (i = 0; i < 5; i++) { | 19 | for (i = 0; i < argc; i++) { |
14 | char buffer[10]; | 20 | char buffer[10]; |
15 | error = add_color(cmd_name, buffer, argv[i]); | 21 | error = add_color(cmd_name, buffer, argv[i]); |
16 | if (error) { | 22 | if (error) { |
17 | return error; | 23 | return error; |
18 | } | 24 | } |
19 | colors[i] = strtoul(buffer+1, NULL, 16); | 25 | *colors[i] = strtoul(buffer + 1, NULL, 16); |
20 | } | 26 | } |
21 | 27 | ||
22 | border_colors->border = colors[0]; | ||
23 | border_colors->background = colors[1]; | ||
24 | border_colors->text = colors[2]; | ||
25 | border_colors->indicator = colors[3]; | ||
26 | border_colors->child_border = colors[4]; | ||
27 | |||
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
29 | } | 29 | } |
30 | 30 | ||