diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-02 08:40:38 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-02 08:40:38 +1000 |
commit | daab8e35038e74f9b21b62cc2d7f74635fb5a34b (patch) | |
tree | 7ae5f7973d3aeef506252c1b9f72e1b110ffbcfe /sway/commands | |
parent | c82a04e110b55c37a24fb5175e35ab8e5bec534c (diff) | |
download | sway-daab8e35038e74f9b21b62cc2d7f74635fb5a34b.tar.xz |
Support alpha in border colours
The alpha component is merged with the container's opacity.
Completes #1882.
Diffstat (limited to 'sway/commands')
-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]) { return false; } - if (strlen(hexstring) != 7) { + if (strlen(hexstring) != 7 && strlen(hexstring) != 9) { return false; } @@ -20,10 +20,15 @@ static bool parse_color(char *hexstring, float dest[static 4]) { return false; } - dest[0] = ((decimal >> 16) & 0xff) / 255.0; - dest[1] = ((decimal >> 8) & 0xff) / 255.0; - dest[2] = (decimal & 0xff) / 255.0; - dest[3] = 1.0; + if (strlen(hexstring) == 6) { + // Add alpha + decimal = (decimal << 8) | 0xff; + } + + dest[0] = ((decimal >> 24) & 0xff) / 255.0; + dest[1] = ((decimal >> 16) & 0xff) / 255.0; + dest[2] = ((decimal >> 8) & 0xff) / 255.0; + dest[3] = (decimal & 0xff) / 255.0; return true; } |