diff options
author | Drew DeVault <[email protected]> | 2018-05-03 08:20:27 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2018-05-03 08:20:27 -0400 |
commit | 87e65e5c5b95e1b7c58bd1b722c97ebe0db8b477 (patch) | |
tree | e3ca897c922da50ec0fd68ed097acf1b7153f61f /sway/commands/client.c | |
parent | f3d0885524f4f1dc568baf21fcc8e387a316703f (diff) | |
parent | 58a033d8163c922eff8577b34523418c2c2ab432 (diff) |
Merge pull request #1895 from RyanDwyer/show-titles
Render titles
Diffstat (limited to 'sway/commands/client.c')
-rw-r--r-- | sway/commands/client.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/sway/commands/client.c b/sway/commands/client.c index c3dc2ee2..d6b7de1a 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c @@ -3,7 +3,10 @@ #include "sway/config.h" #include "sway/tree/container.h" -static bool parse_color(char *hexstring, float dest[static 4]) { +/** + * Parse the hex string into an integer. + */ +static bool parse_color_int(char *hexstring, uint32_t *dest) { if (hexstring[0] != '#') { return false; } @@ -25,6 +28,18 @@ static bool parse_color(char *hexstring, float dest[static 4]) { decimal = (decimal << 8) | 0xff; } + *dest = decimal; + return true; +} + +/** + * Parse the hex string into a float value. + */ +static bool parse_color_float(char *hexstring, float dest[static 4]) { + uint32_t decimal; + if (!parse_color_int(hexstring, &decimal)) { + return false; + } dest[0] = ((decimal >> 24) & 0xff) / 255.0; dest[1] = ((decimal >> 16) & 0xff) / 255.0; dest[2] = ((decimal >> 8) & 0xff) / 255.0; @@ -39,27 +54,27 @@ static struct cmd_results *handle_command(int argc, char **argv, return error; } - if (!parse_color(argv[0], class->border)) { + if (!parse_color_float(argv[0], class->border)) { return cmd_results_new(CMD_INVALID, cmd_name, "Unable to parse border color"); } - if (!parse_color(argv[1], class->background)) { + if (!parse_color_float(argv[1], class->background)) { return cmd_results_new(CMD_INVALID, cmd_name, "Unable to parse background color"); } - if (!parse_color(argv[2], class->text)) { + if (!parse_color_float(argv[2], class->text)) { return cmd_results_new(CMD_INVALID, cmd_name, "Unable to parse text color"); } - if (!parse_color(argv[3], class->indicator)) { + if (!parse_color_float(argv[3], class->indicator)) { return cmd_results_new(CMD_INVALID, cmd_name, "Unable to parse indicator color"); } - if (!parse_color(argv[4], class->child_border)) { + if (!parse_color_float(argv[4], class->child_border)) { return cmd_results_new(CMD_INVALID, cmd_name, "Unable to parse child border color"); } |