RGBA colors now should render properly.

This commit is contained in:
LemonBoy 2014-06-11 20:34:40 +02:00
commit 970332ac76
1 changed files with 10 additions and 2 deletions

12
bar.c
View File

@ -156,9 +156,17 @@ parse_color (const char *str, char **end, const uint32_t def)
if (str[0] == '#') {
errno = 0;
uint32_t tmp = strtoul(str + 1, end, 16);
/* Some error checking it's good */
/* Some error checking is definitely good */
if (errno)
return def;
tmp = def;
/* Xorg uses colors with premultiplied alpha.
* Don't do anything if we didn't acquire a rgba visual. */
if (visual != scr->root_visual) {
const uint8_t a = ((tmp>>24)&255);
const uint32_t t1 = (tmp&0xff00ff) * (0x100-a);
const uint32_t t2 = (tmp&0x00ff00) * (0x100-a);
tmp = (a<<24)|(t1&0xff00ff)|(t2&0x00ff00);
}
return tmp;
}