mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 08:37:17 +00:00
Fix color parsing
This commit is contained in:
parent
461df2ed81
commit
7aa289d90c
1 changed files with 19 additions and 2 deletions
|
@ -566,8 +566,25 @@ Color color_get ( const char *const name )
|
|||
color.pixel = strtoul ( &cname[5], NULL, 16 );
|
||||
}
|
||||
else if ( strncmp ( cname, "#", 1 ) == 0 ) {
|
||||
color.pixel = strtoul ( &cname[1], NULL, 16 );
|
||||
color.a = 0xff;
|
||||
unsigned long val = strtoul ( &cname[1], NULL, 16 );
|
||||
ssize_t length = strlen(&cname[1]);
|
||||
switch ( length ) {
|
||||
case 3:
|
||||
color.a = 0xff;
|
||||
color.r = 16*((val&0xF00)>>8);
|
||||
color.g = 16*((val&0x0F0)>>4);
|
||||
color.b = 16*(val&0x00F);
|
||||
break;
|
||||
case 6:
|
||||
color.pixel = val;
|
||||
color.a = 0xff;
|
||||
break;
|
||||
case 8:
|
||||
color.pixel = val;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_free ( copy );
|
||||
|
||||
|
|
Loading…
Reference in a new issue