diff options
Diffstat (limited to 'sway/commands/client.c')
-rw-r--r-- | sway/commands/client.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sway/commands/client.c b/sway/commands/client.c index 156ff95c..c3dc2ee2 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c | |||
@@ -8,7 +8,7 @@ static bool parse_color(char *hexstring, float dest[static 4]) { | |||
8 | return false; | 8 | return false; |
9 | } | 9 | } |
10 | 10 | ||
11 | if (strlen(hexstring) != 7) { | 11 | if (strlen(hexstring) != 7 && strlen(hexstring) != 9) { |
12 | return false; | 12 | return false; |
13 | } | 13 | } |
14 | 14 | ||
@@ -20,10 +20,15 @@ static bool parse_color(char *hexstring, float dest[static 4]) { | |||
20 | return false; | 20 | return false; |
21 | } | 21 | } |
22 | 22 | ||
23 | dest[0] = ((decimal >> 16) & 0xff) / 255.0; | 23 | if (strlen(hexstring) == 6) { |
24 | dest[1] = ((decimal >> 8) & 0xff) / 255.0; | 24 | // Add alpha |
25 | dest[2] = (decimal & 0xff) / 255.0; | 25 | decimal = (decimal << 8) | 0xff; |
26 | dest[3] = 1.0; | 26 | } |
27 | |||
28 | dest[0] = ((decimal >> 24) & 0xff) / 255.0; | ||
29 | dest[1] = ((decimal >> 16) & 0xff) / 255.0; | ||
30 | dest[2] = ((decimal >> 8) & 0xff) / 255.0; | ||
31 | dest[3] = (decimal & 0xff) / 255.0; | ||
27 | return true; | 32 | return true; |
28 | } | 33 | } |
29 | 34 | ||