change draw_color_new() proto to fill the struct and return status
This commit is contained in:
parent
0b6129e625
commit
ae75f55acd
|
@ -104,10 +104,12 @@ config_parse(const char *confpatharg)
|
|||
cfg_colors = cfg_getsec(cfg_screen, "colors");
|
||||
|
||||
/* colors */
|
||||
globalconf.fg = draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
|
||||
cfg_getstr(cfg_colors, "normal_fg"));
|
||||
globalconf.bg = draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
|
||||
cfg_getstr(cfg_colors, "normal_bg"));
|
||||
draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
|
||||
cfg_getstr(cfg_colors, "normal_fg"),
|
||||
&globalconf.fg);
|
||||
draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
|
||||
cfg_getstr(cfg_colors, "normal_bg"),
|
||||
&globalconf.bg);
|
||||
|
||||
/* font */
|
||||
globalconf.font = XftFontOpenName(globalconf.display, DefaultScreen(globalconf.display),
|
||||
|
|
|
@ -563,19 +563,20 @@ draw_get_align(const char *align)
|
|||
* \param colstr Color specification
|
||||
* \return XColor struct
|
||||
*/
|
||||
XColor
|
||||
draw_color_new(Display *disp, int phys_screen, const char *colstr)
|
||||
Bool
|
||||
draw_color_new(Display *disp, int phys_screen, const char *colstr, XColor *color)
|
||||
{
|
||||
XColor screenColor, exactColor;
|
||||
Bool ret;
|
||||
XColor exactColor;
|
||||
|
||||
if(!XAllocNamedColor(disp,
|
||||
if(!(ret = XAllocNamedColor(disp,
|
||||
DefaultColormap(disp, phys_screen),
|
||||
colstr,
|
||||
&screenColor,
|
||||
&exactColor))
|
||||
eprint("awesome: error, cannot allocate color '%s'\n", colstr);
|
||||
color,
|
||||
&exactColor)))
|
||||
warn("awesome: error, cannot allocate color '%s'\n", colstr);
|
||||
|
||||
return screenColor;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Remove a area from a list of them,
|
||||
|
|
|
@ -109,7 +109,7 @@ Area draw_get_image_size(const char *filename);
|
|||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||
unsigned short draw_textwidth(Display *, XftFont *, char *);
|
||||
Alignment draw_get_align(const char *);
|
||||
XColor draw_color_new(Display *, int, const char *);
|
||||
Bool draw_color_new(Display *, int, const char *, XColor *);
|
||||
|
||||
void area_list_remove(Area **, Area *);
|
||||
|
||||
|
|
40
config.c
40
config.c
|
@ -321,22 +321,30 @@ config_parse_screen(cfg_t *cfg, int screen)
|
|||
eprint("awesome: cannot init font\n");
|
||||
|
||||
/* Colors */
|
||||
virtscreen->colors_normal[ColBorder] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "normal_border"));
|
||||
virtscreen->colors_normal[ColBG] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "normal_bg"));
|
||||
virtscreen->colors_normal[ColFG] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "normal_fg"));
|
||||
virtscreen->colors_selected[ColBorder] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "focus_border"));
|
||||
virtscreen->colors_selected[ColBG] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "focus_bg"));
|
||||
virtscreen->colors_selected[ColFG] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "focus_fg"));
|
||||
virtscreen->colors_urgent[ColBG] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "urgent_bg"));
|
||||
virtscreen->colors_urgent[ColFG] = draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "urgent_fg"));
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "normal_border"),
|
||||
&virtscreen->colors_normal[ColBorder]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "normal_bg"),
|
||||
&virtscreen->colors_normal[ColBG]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "normal_fg"),
|
||||
&virtscreen->colors_normal[ColFG]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "focus_border"),
|
||||
&virtscreen->colors_selected[ColBorder]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "focus_bg"),
|
||||
&virtscreen->colors_selected[ColBG]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "focus_fg"),
|
||||
&virtscreen->colors_selected[ColFG]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "urgent_bg"),
|
||||
&virtscreen->colors_urgent[ColBG]);
|
||||
draw_color_new(globalconf.display, phys_screen,
|
||||
cfg_getstr(cfg_colors, "urgent_fg"),
|
||||
&virtscreen->colors_urgent[ColFG]);
|
||||
|
||||
/* Statusbar */
|
||||
|
||||
|
|
|
@ -302,20 +302,20 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
|||
cfg = cfg_getnsec(config, "data", i);
|
||||
|
||||
if((color = cfg_getstr(cfg, "fg")))
|
||||
tmp_color = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, &tmp_color);
|
||||
else
|
||||
tmp_color = globalconf.screens[statusbar->screen].colors_normal[ColFG];
|
||||
|
||||
if((color = cfg_getstr(cfg, "fg_center")))
|
||||
{
|
||||
ptmp_color_center = p_new(XColor, 1);
|
||||
*ptmp_color_center = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, ptmp_color_center);
|
||||
}
|
||||
|
||||
if((color = cfg_getstr(cfg, "fg_end")))
|
||||
{
|
||||
ptmp_color_end = p_new(XColor, 1);
|
||||
*ptmp_color_end = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, ptmp_color_center);
|
||||
}
|
||||
|
||||
if (cfg_getbool(cfg, "scale"))
|
||||
|
@ -364,12 +364,12 @@ graph_new(Statusbar *statusbar, cfg_t *config)
|
|||
}
|
||||
|
||||
if((color = cfg_getstr(config, "bg")))
|
||||
d->bg = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, &d->bg);
|
||||
else
|
||||
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
|
||||
|
||||
if((color = cfg_getstr(config, "bordercolor")))
|
||||
d->bordercolor = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, &d->bordercolor);
|
||||
else
|
||||
d->bordercolor = tmp_color;
|
||||
|
||||
|
|
|
@ -169,29 +169,29 @@ progressbar_new(Statusbar *statusbar, cfg_t *config)
|
|||
cfg = cfg_getnsec(config, "bar", i);
|
||||
|
||||
if((color = cfg_getstr(cfg, "fg")))
|
||||
d->fg[i] = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, &d->fg[i]);
|
||||
else
|
||||
d->fg[i] = globalconf.screens[statusbar->screen].colors_normal[ColFG];
|
||||
|
||||
if((color = cfg_getstr(cfg, "fg_center")))
|
||||
{
|
||||
d->pfg_center[i] = p_new(XColor, 1);
|
||||
*(d->pfg_center[i]) = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, d->pfg_center[i]);
|
||||
}
|
||||
|
||||
if((color = cfg_getstr(cfg, "fg_end")))
|
||||
{
|
||||
d->pfg_end[i] = p_new(XColor, 1);
|
||||
*(d->pfg_end[i]) = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, d->pfg_end[i]);
|
||||
}
|
||||
|
||||
if((color = cfg_getstr(cfg, "bg")))
|
||||
d->bg[i] = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, &d->bg[i]);
|
||||
else
|
||||
d->bg[i] = globalconf.screens[statusbar->screen].colors_normal[ColBG];
|
||||
|
||||
if((color = cfg_getstr(cfg, "bordercolor")))
|
||||
d->bordercolor[i] = draw_color_new(globalconf.display, phys_screen, color);
|
||||
draw_color_new(globalconf.display, phys_screen, color, &d->bordercolor[i]);
|
||||
else
|
||||
d->bordercolor[i] = d->fg[i];
|
||||
}
|
||||
|
|
|
@ -277,22 +277,22 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
|
|||
w->data = d = p_new(Data, 1);
|
||||
|
||||
if((buf = cfg_getstr(config, "fg")))
|
||||
d->fg = draw_color_new(globalconf.display, phys_screen, buf);
|
||||
draw_color_new(globalconf.display, phys_screen, buf, &d->fg);
|
||||
else
|
||||
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG];
|
||||
|
||||
if((buf = cfg_getstr(config, "bg")))
|
||||
d->bg = draw_color_new(globalconf.display, phys_screen, buf);
|
||||
draw_color_new(globalconf.display, phys_screen, buf, &d->bg);
|
||||
else
|
||||
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
|
||||
|
||||
if((buf = cfg_getstr(config, "focus_bg")))
|
||||
d->bg_sel = draw_color_new(globalconf.display, phys_screen, buf);
|
||||
draw_color_new(globalconf.display, phys_screen, buf, &d->bg_sel);
|
||||
else
|
||||
d->bg_sel = globalconf.screens[statusbar->screen].colors_selected[ColBG];
|
||||
|
||||
if((buf = cfg_getstr(config, "focus_fg")))
|
||||
d->fg_sel = draw_color_new(globalconf.display, phys_screen, buf);
|
||||
draw_color_new(globalconf.display, phys_screen, buf, &d->fg_sel);
|
||||
else
|
||||
d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG];
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ textbox_tell(Widget *widget, char *command)
|
|||
if(ntok)
|
||||
*ntok = 0;
|
||||
if(!i)
|
||||
d->fg = draw_color_new(globalconf.display, phys_screen, tok);
|
||||
draw_color_new(globalconf.display, phys_screen, tok, &d->fg);
|
||||
else
|
||||
d->bg = draw_color_new(globalconf.display, phys_screen, tok);
|
||||
draw_color_new(globalconf.display, phys_screen, tok, &d->bg);
|
||||
if (ntok)
|
||||
*ntok = ' ';
|
||||
tok = ntok + (ntok != NULL);
|
||||
|
@ -109,12 +109,12 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
|
|||
w->data = d = p_new(Data, 1);
|
||||
|
||||
if((buf = cfg_getstr(config, "fg")))
|
||||
d->fg = draw_color_new(globalconf.display, statusbar->screen, buf);
|
||||
draw_color_new(globalconf.display, statusbar->screen, buf, &d->fg);
|
||||
else
|
||||
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG];
|
||||
|
||||
if((buf = cfg_getstr(config, "bg")))
|
||||
d->bg = draw_color_new(globalconf.display, get_phys_screen(statusbar->screen), buf);
|
||||
draw_color_new(globalconf.display, get_phys_screen(statusbar->screen), buf, &d->bg);
|
||||
else
|
||||
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
|
||||
|
||||
|
|
Loading…
Reference in New Issue