From b667298a0a1efead7949715a31ec86fe3b8b1cda Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 2 May 2018 23:07:52 +1000 Subject: Render titles --- sway/commands/client.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'sway/commands/client.c') diff --git a/sway/commands/client.c b/sway/commands/client.c index c3dc2ee2..0abd0167 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_int(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"); } -- cgit v1.2.3 From 58a033d8163c922eff8577b34523418c2c2ab432 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 3 May 2018 08:14:17 -0400 Subject: Convert border_colors.text to float[4] --- sway/commands/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/commands/client.c') diff --git a/sway/commands/client.c b/sway/commands/client.c index 0abd0167..d6b7de1a 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c @@ -64,7 +64,7 @@ static struct cmd_results *handle_command(int argc, char **argv, "Unable to parse background color"); } - if (!parse_color_int(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"); } -- cgit v1.2.3