diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-02 23:07:52 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-03 15:12:00 +1000 |
commit | b667298a0a1efead7949715a31ec86fe3b8b1cda (patch) | |
tree | bc658e3019d741f1f245350003b156d05cc354a2 /sway/commands/client.c | |
parent | Merge pull request #1893 from swaywm/touch (diff) | |
download | sway-b667298a0a1efead7949715a31ec86fe3b8b1cda.tar.gz sway-b667298a0a1efead7949715a31ec86fe3b8b1cda.tar.zst sway-b667298a0a1efead7949715a31ec86fe3b8b1cda.zip |
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..0abd0167 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c | |||
@@ -3,7 +3,10 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/tree/container.h" | 4 | #include "sway/tree/container.h" |
5 | 5 | ||
6 | static bool parse_color(char *hexstring, float dest[static 4]) { | 6 | /** |
7 | * Parse the hex string into an integer. | ||
8 | */ | ||
9 | static bool parse_color_int(char *hexstring, uint32_t *dest) { | ||
7 | if (hexstring[0] != '#') { | 10 | if (hexstring[0] != '#') { |
8 | return false; | 11 | return false; |
9 | } | 12 | } |
@@ -25,6 +28,18 @@ static bool parse_color(char *hexstring, float dest[static 4]) { | |||
25 | decimal = (decimal << 8) | 0xff; | 28 | decimal = (decimal << 8) | 0xff; |
26 | } | 29 | } |
27 | 30 | ||
31 | *dest = decimal; | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | /** | ||
36 | * Parse the hex string into a float value. | ||
37 | */ | ||
38 | static bool parse_color_float(char *hexstring, float dest[static 4]) { | ||
39 | uint32_t decimal; | ||
40 | if (!parse_color_int(hexstring, &decimal)) { | ||
41 | return false; | ||
42 | } | ||
28 | dest[0] = ((decimal >> 24) & 0xff) / 255.0; | 43 | dest[0] = ((decimal >> 24) & 0xff) / 255.0; |
29 | dest[1] = ((decimal >> 16) & 0xff) / 255.0; | 44 | dest[1] = ((decimal >> 16) & 0xff) / 255.0; |
30 | dest[2] = ((decimal >> 8) & 0xff) / 255.0; | 45 | dest[2] = ((decimal >> 8) & 0xff) / 255.0; |
@@ -39,27 +54,27 @@ static struct cmd_results *handle_command(int argc, char **argv, | |||
39 | return error; | 54 | return error; |
40 | } | 55 | } |
41 | 56 | ||
42 | if (!parse_color(argv[0], class->border)) { | 57 | if (!parse_color_float(argv[0], class->border)) { |
43 | return cmd_results_new(CMD_INVALID, cmd_name, | 58 | return cmd_results_new(CMD_INVALID, cmd_name, |
44 | "Unable to parse border color"); | 59 | "Unable to parse border color"); |
45 | } | 60 | } |
46 | 61 | ||
47 | if (!parse_color(argv[1], class->background)) { | 62 | if (!parse_color_float(argv[1], class->background)) { |
48 | return cmd_results_new(CMD_INVALID, cmd_name, | 63 | return cmd_results_new(CMD_INVALID, cmd_name, |
49 | "Unable to parse background color"); | 64 | "Unable to parse background color"); |
50 | } | 65 | } |
51 | 66 | ||
52 | if (!parse_color(argv[2], class->text)) { | 67 | if (!parse_color_int(argv[2], &class->text)) { |
53 | return cmd_results_new(CMD_INVALID, cmd_name, | 68 | return cmd_results_new(CMD_INVALID, cmd_name, |
54 | "Unable to parse text color"); | 69 | "Unable to parse text color"); |
55 | } | 70 | } |
56 | 71 | ||
57 | if (!parse_color(argv[3], class->indicator)) { | 72 | if (!parse_color_float(argv[3], class->indicator)) { |
58 | return cmd_results_new(CMD_INVALID, cmd_name, | 73 | return cmd_results_new(CMD_INVALID, cmd_name, |
59 | "Unable to parse indicator color"); | 74 | "Unable to parse indicator color"); |
60 | } | 75 | } |
61 | 76 | ||
62 | if (!parse_color(argv[4], class->child_border)) { | 77 | if (!parse_color_float(argv[4], class->child_border)) { |
63 | return cmd_results_new(CMD_INVALID, cmd_name, | 78 | return cmd_results_new(CMD_INVALID, cmd_name, |
64 | "Unable to parse child border color"); | 79 | "Unable to parse child border color"); |
65 | } | 80 | } |