diff options
Diffstat (limited to 'src/colors.c')
-rw-r--r-- | src/colors.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/colors.c b/src/colors.c index 9a4c8c8e..6a684dde 100644 --- a/src/colors.c +++ b/src/colors.c @@ -204,7 +204,7 @@ static const struct key { #define NCOLORS (sizeof(color_keyword) / sizeof(struct key)) /* - * Parse a color in hex (RRGGBB) + * Parse a color in hex (RRGGBB) or (RGB) * * Return Value: * parsed color if successful (err = 0), @@ -219,7 +219,12 @@ static int32_t Color_parse_hex (const char *s, int32_t default_color, int *err) ret_color = strtol(s, &tail, 16); if (tail - s == 6) *err = 0; - else + else if (tail - s == 3) { /* #RGB as allowed by CSS */ + *err = 0; + ret_color = ((ret_color & 0xf00) << 12) | ((ret_color & 0xf00) << 8) | + ((ret_color & 0x0f0) << 8) | ((ret_color & 0x0f0) << 4) | + ((ret_color & 0x00f) << 4) | ((ret_color & 0x00f) << 0); + } else ret_color = default_color; return ret_color; |