Remove old color structure and name based parsing

This commit is contained in:
Dave Davenport 2017-03-30 08:30:02 +02:00
parent eeee200d8f
commit 898e4a2717
4 changed files with 2 additions and 88 deletions

View File

@ -1,5 +1,7 @@
# Convert old themes to the new format
> This is now invalid, old theme support has been removed and will be part of a separate tool.
**Rofi** 1.4 can still read in and convert the old theme format. To read the old format, convert it, and dump it into a
new file run:

View File

@ -26,7 +26,6 @@ typedef struct
widget widget;
unsigned long flags;
short cursor;
Color color_fg, color_bg;
char *text;
PangoLayout *layout;
int tbft;

View File

@ -196,27 +196,6 @@ extern xcb_colormap_t map;
*/
void x11_create_visual_and_colormap ( void );
/**
* Structure describing a cairo color.
*/
typedef struct
{
/** red channel */
double red;
/** green channel */
double green;
/** blue channel */
double blue;
/** alpha channel */
double alpha;
} Color;
/**
* @param name String representing the color.
*
* Allocate a pixel value for an X named color
*/
Color color_get ( const char *const name );
/**
* Gets a surface containing the background image of the desktop.

View File

@ -807,72 +807,6 @@ void x11_create_visual_and_colormap ( void )
}
}
Color color_get ( const char *const name )
{
char *copy = g_strdup ( name );
char *cname = g_strstrip ( copy );
union
{
struct
{
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t a;
} sep;
uint32_t pixel;
} color = {
.pixel = 0xffffffff,
};
// Special format.
if ( strncmp ( cname, "argb:", 5 ) == 0 ) {
color.pixel = strtoul ( &cname[5], NULL, 16 );
}
else if ( strncmp ( cname, "#", 1 ) == 0 ) {
unsigned long val = strtoul ( &cname[1], NULL, 16 );
ssize_t length = strlen ( &cname[1] );
switch ( length )
{
case 3:
color.sep.a = 0xff;
color.sep.r = 16 * ( ( val & 0xF00 ) >> 8 );
color.sep.g = 16 * ( ( val & 0x0F0 ) >> 4 );
color.sep.b = 16 * ( val & 0x00F );
break;
case 6:
color.pixel = val;
color.sep.a = 0xff;
break;
case 8:
color.pixel = val;
break;
default:
break;
}
}
else {
xcb_alloc_named_color_cookie_t cc = xcb_alloc_named_color ( xcb->connection,
map, strlen ( cname ), cname );
xcb_alloc_named_color_reply_t *r = xcb_alloc_named_color_reply ( xcb->connection, cc, NULL );
if ( r ) {
color.sep.a = 0xFF;
color.sep.r = r->visual_red;
color.sep.g = r->visual_green;
color.sep.b = r->visual_blue;
free ( r );
}
}
g_free ( copy );
Color ret = {
.red = color.sep.r / 255.0,
.green = color.sep.g / 255.0,
.blue = color.sep.b / 255.0,
.alpha = color.sep.a / 255.0,
};
return ret;
}
xcb_window_t xcb_stuff_get_root_window ( xcb_stuff *xcb )
{