Change colors handling

This commit is contained in:
Julien Danjou 2008-03-13 17:57:38 +01:00
parent a0ba05b904
commit 9dfd488dda
9 changed files with 116 additions and 156 deletions

View File

@ -123,6 +123,7 @@ config_parse(const char *confpatharg, const char *menu_title, Area *geometry)
char *confpath, *opt; char *confpath, *opt;
cfg_t *cfg, *cfg_menu = NULL, *cfg_screen, *cfg_general, cfg_t *cfg, *cfg_menu = NULL, *cfg_screen, *cfg_general,
*cfg_colors, *cfg_menu_colors = NULL; *cfg_colors, *cfg_menu_colors = NULL;
colors_ctx_t colors_normal, colors_focus;
if(!confpatharg) if(!confpatharg)
confpath = config_file(); confpath = config_file();
@ -157,41 +158,34 @@ config_parse(const char *confpatharg, const char *menu_title, Area *geometry)
cfg_general = cfg_getsec(cfg_screen, "general"); cfg_general = cfg_getsec(cfg_screen, "general");
cfg_colors = cfg_getsec(cfg_screen, "colors"); cfg_colors = cfg_getsec(cfg_screen, "colors");
/* colors */ /* Colors */
if(!cfg_menu_colors || !(opt = cfg_getstr(cfg_menu_colors, "normal_fg")))
opt = cfg_getstr(cfg_colors, "normal_fg");
draw_color_new(globalconf.display, DefaultScreen(globalconf.display), /* Grab default colors */
opt, &globalconf.colors.normal.fg); draw_colors_ctx_init(globalconf.display, DefaultScreen(globalconf.display),
cfg_getsec(cfg_colors, "normal"),
&colors_normal, NULL);
if(!cfg_menu_colors || !(opt = cfg_getstr(cfg_menu_colors, "normal_bg"))) draw_colors_ctx_init(globalconf.display, DefaultScreen(globalconf.display),
opt = cfg_getstr(cfg_colors, "normal_bg"); cfg_getsec(cfg_colors, "normal"),
&colors_normal, NULL);
draw_color_new(globalconf.display, DefaultScreen(globalconf.display), /* Now grab menu colors if any */
opt, &globalconf.colors.normal.bg); draw_colors_ctx_init(globalconf.display, DefaultScreen(globalconf.display),
cfg_getsec(cfg_colors, "normal"),
&globalconf.colors.normal, &colors_normal);
if(!cfg_menu_colors || !(opt = cfg_getstr(cfg_menu_colors, "focus_fg"))) draw_colors_ctx_init(globalconf.display, DefaultScreen(globalconf.display),
opt = cfg_getstr(cfg_colors, "focus_fg"); cfg_getsec(cfg_colors, "focus"),
&globalconf.colors.focus, &colors_focus);
draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
opt, &globalconf.colors.focus.fg);
if(!cfg_menu_colors || !(opt = cfg_getstr(cfg_menu_colors, "focus_bg")))
opt = cfg_getstr(cfg_colors, "focus_bg");
draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
opt, &globalconf.colors.focus.bg);
/* font */ /* font */
if(!cfg_menu || !(opt = cfg_getstr(cfg_menu, "font"))) if(!cfg_menu || !(opt = cfg_getstr(cfg_menu, "font")))
opt = cfg_getstr(cfg_general, "font"); opt = cfg_getstr(cfg_general, "font");
globalconf.font = XftFontOpenName(globalconf.display, DefaultScreen(globalconf.display), globalconf.font = XftFontOpenName(globalconf.display,
DefaultScreen(globalconf.display),
opt); opt);
globalconf.colors.normal.shadow_offset =
globalconf.colors.focus.shadow_offset = cfg_getint(cfg_general, "text_shadow_offset");
if(cfg_menu) if(cfg_menu)
{ {
if((i = cfg_getint(cfg_menu, "x")) != (int) 0xffffffff) if((i = cfg_getint(cfg_menu, "x")) != (int) 0xffffffff)

View File

@ -102,14 +102,9 @@ config_parse(const char *confpatharg)
cfg_colors = cfg_getsec(cfg_screen, "colors"); cfg_colors = cfg_getsec(cfg_screen, "colors");
/* colors */ /* colors */
draw_color_new(globalconf.display, DefaultScreen(globalconf.display), draw_colors_ctx_init(globalconf.display, DefaultScreen(globalconf.display),
cfg_getstr(cfg_colors, "normal_fg"), cfg_getsec(cfg_colors, "normal"),
&globalconf.colors.fg); &globalconf.colors, NULL);
draw_color_new(globalconf.display, DefaultScreen(globalconf.display),
cfg_getstr(cfg_colors, "normal_bg"),
&globalconf.colors.bg);
globalconf.colors.shadow_offset = cfg_getint(cfg_general, "text_shadow_offset");
/* font */ /* font */
globalconf.font = XftFontOpenName(globalconf.display, DefaultScreen(globalconf.display), globalconf.font = XftFontOpenName(globalconf.display, DefaultScreen(globalconf.display),

View File

@ -100,26 +100,19 @@ image::
colors colors
^^^^^^ ^^^^^^
Colors is a section containing the color parameters. Colors is a section containing the colors parameters which is composed of a normal, focus and urgent
subsection each ones containing:
normal_fg:: fg::
Set the normal foreground color. Set the foreground color.
normal_bg:: bg::
Set the normal background color. Set the background color.
normal_border:: border::
Set the unfocused window's border color. Set the window's border color.
focus_fg:: shadow::
Set the focused foreground color. Set the shadow color.
focus_bg:: shadow_offset::
Set the focused background color. Set the shadow offset in pixel.
focus_border::
Set the focused window's border color.
urgent_fg::
Set the foreground color to use for urgent flag. This is mostly useful
with the taglist widget which will use this color whenever a window sets its
XUrgencyHint on a non-visible tag.
urgent_bg::
Set the background color to use for urgent flag.
padding padding
^^^^^^^ ^^^^^^^
@ -393,12 +386,8 @@ This widget shows a list of running windows.
Font to use. Font to use.
*bg*:: *bg*::
Background color. Background color.
*fg*:: *colors*::
Foreground color. Colors section with a focus and normal subsection.
*focus_bg*::
Background color for focused window.
*focus_fg*::
Foreground color for focused window.
*text_align*:: *text_align*::
Text alignement. Text alignement.
*show_icons*:: *show_icons*::
@ -418,12 +407,10 @@ This widget shows a text.
Set mouse bindings. Set mouse bindings.
*font*:: *font*::
Font to use. Font to use.
*bg*::
Background color.
*fg*::
Foreground color.
*width*:: *width*::
Set width. Set width.
*colors*::
Colors section with a focus and normal subsection.
*text*:: *text*::
Text to change. Text to change.
*text_align*:: *text_align*::
@ -551,11 +538,11 @@ Note: when there is no whitespace, quotes are optional.
<uicb-arg> -> prog, 3... (argument to a uicb function, where required) <uicb-arg> -> prog, 3... (argument to a uicb function, where required)
<uicb-cmd> -> spawn, exec, client_tag... (see UICB FUNCTIONS above) <uicb-cmd> -> spawn, exec, client_tag... (see UICB FUNCTIONS above)
<{.., ...}> -> list of available options <{.., ...}> -> list of available options
<color section> -> a section with fg, bg, border, shadow and shadow_offset options.
[MULTI] means, you can use an item multiple times. [MULTI] means, you can use an item multiple times.
screen <integer> [MULTI] screen <integer> [MULTI]
{ {
general general
@ -570,7 +557,6 @@ screen <integer> [MULTI]
sloppy_focus_raise = <boolean> sloppy_focus_raise = <boolean>
snap = <integer> snap = <integer>
floating_placement = <{smart,under_mouse}> floating_placement = <{smart,under_mouse}>
text_shadow_offset = <int>
mwfact_lower_limit = <float> mwfact_lower_limit = <float>
mwfact_upper_limit = <float> mwfact_upper_limit = <float>
} }
@ -593,14 +579,9 @@ screen <integer> [MULTI]
} }
colors colors
{ {
normal_fg = <color> normal { <color section> }
normal_bg = <color> focus { <color section> }
normal_border = <color> urgent { <color section> }
focus_fg = <color>
focus_bg = <color>
focus_border = <color>
urgent_fg = <color>
urgent_bg = <color>
} }
padding padding
{ {
@ -647,10 +628,11 @@ screen <integer> [MULTI]
} }
tasklist <identifier> tasklist <identifier>
{ {
fg = <color> colors
bg = <color> {
focus_fg = <color> normal { <color section> }
focus_bg = <color> focus { <color section> }
}
font = <font> font = <font>
show_icons = <boolean> show_icons = <boolean>
show = <{all,tags,focus}> show = <{all,tags,focus}>

View File

@ -77,7 +77,6 @@ cfg_opt_t general_opts[] =
CFG_BOOL((char *) "new_become_master", cfg_true, CFGF_NONE), CFG_BOOL((char *) "new_become_master", cfg_true, CFGF_NONE),
CFG_BOOL((char *) "new_get_focus", cfg_true, CFGF_NONE), CFG_BOOL((char *) "new_get_focus", cfg_true, CFGF_NONE),
CFG_STR((char *) "font", (char *) "vera-10", CFGF_NONE), CFG_STR((char *) "font", (char *) "vera-10", CFGF_NONE),
CFG_INT((char *) "text_shadow_offset", 1, CFGF_NONE),
CFG_INT((char *) "opacity_unfocused", -1, CFGF_NONE), CFG_INT((char *) "opacity_unfocused", -1, CFGF_NONE),
CFG_STR((char *) "floating_placement", (char *) "smart", CFGF_NONE), CFG_STR((char *) "floating_placement", (char *) "smart", CFGF_NONE),
CFG_FLOAT((char *) "mwfact_lower_limit", 0.1, CFGF_NONE), CFG_FLOAT((char *) "mwfact_lower_limit", 0.1, CFGF_NONE),
@ -86,14 +85,18 @@ cfg_opt_t general_opts[] =
}; };
cfg_opt_t colors_opts[] = cfg_opt_t colors_opts[] =
{ {
CFG_STR((char *) "normal_border", (char *) "#111111", CFGF_NONE), CFG_STR((char *) "border", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "normal_bg", (char *) "#111111", CFGF_NONE), CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "normal_fg", (char *) "#eeeeee", CFGF_NONE), CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "focus_border", (char *) "#6666ff", CFGF_NONE), CFG_STR((char *) "shadow", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "focus_bg", (char *) "#6666ff", CFGF_NONE), CFG_INT((char *) "shadow_offset", 0, CFGF_NONE),
CFG_STR((char *) "focus_fg", (char *) "#ffffff", CFGF_NONE), CFG_AWESOME_END()
CFG_STR((char *) "urgent_bg", (char *) "#ff0000", CFGF_NONE), };
CFG_STR((char *) "urgent_fg", (char *) "#ffffff", CFGF_NONE), cfg_opt_t screen_colors_opts[] =
{
CFG_SEC((char *) "normal", colors_opts, CFGF_NONE),
CFG_SEC((char *) "focus", colors_opts, CFGF_NONE),
CFG_SEC((char *) "urgent", colors_opts, CFGF_NONE),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
cfg_opt_t mouse_taglist_opts[] = cfg_opt_t mouse_taglist_opts[] =
@ -145,10 +148,9 @@ cfg_opt_t widget_textbox_opts[] =
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
CFG_INT((char *) "width", 0, CFGF_NONE), CFG_INT((char *) "width", 0, CFGF_NONE),
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE), CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE), CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "text_align", (char *) "center", CFGF_NONE), CFG_STR((char *) "text_align", (char *) "center", CFGF_NONE),
CFG_SEC((char *) "colors", colors_opts, CFGF_NONE),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
cfg_opt_t widget_tasklist_opts[] = cfg_opt_t widget_tasklist_opts[] =
@ -156,10 +158,7 @@ cfg_opt_t widget_tasklist_opts[] =
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE), CFG_SEC((char *) "colors", screen_colors_opts, CFGF_NONE),
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "focus_fg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "focus_bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE), CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "text_align", (char *) "left", CFGF_NONE), CFG_STR((char *) "text_align", (char *) "left", CFGF_NONE),
CFG_STR((char *) "show", (char *) "tags", CFGF_NONE), CFG_STR((char *) "show", (char *) "tags", CFGF_NONE),
@ -266,7 +265,7 @@ cfg_opt_t screen_opts[] =
CFG_SEC((char *) "general", general_opts, CFGF_NONE), CFG_SEC((char *) "general", general_opts, CFGF_NONE),
CFG_SEC((char *) "statusbar", statusbar_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES), CFG_SEC((char *) "statusbar", statusbar_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
CFG_SEC((char *) "tags", tags_opts, CFGF_NONE), CFG_SEC((char *) "tags", tags_opts, CFGF_NONE),
CFG_SEC((char *) "colors", colors_opts, CFGF_NONE), CFG_SEC((char *) "colors", screen_colors_opts, CFGF_NONE),
CFG_SEC((char *) "layouts", layouts_opts, CFGF_NONE), CFG_SEC((char *) "layouts", layouts_opts, CFGF_NONE),
CFG_SEC((char *) "padding", padding_opts, CFGF_NONE), CFG_SEC((char *) "padding", padding_opts, CFGF_NONE),
CFG_AWESOME_END() CFG_AWESOME_END()
@ -317,14 +316,6 @@ cfg_opt_t mouse_opts[] =
CFG_SEC((char *) "client", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "client", mouse_generic_opts, CFGF_MULTI),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
cfg_opt_t menu_colors_opts[] =
{
CFG_STR((char *) "normal_bg", NULL, CFGF_NONE),
CFG_STR((char *) "normal_fg", NULL, CFGF_NONE),
CFG_STR((char *) "focus_bg", NULL, CFGF_NONE),
CFG_STR((char *) "focus_fg", NULL, CFGF_NONE),
CFG_AWESOME_END()
};
cfg_opt_t menu_opts[] = cfg_opt_t menu_opts[] =
{ {
CFG_INT((char *) "width", 0, CFGF_NONE), CFG_INT((char *) "width", 0, CFGF_NONE),
@ -332,7 +323,7 @@ cfg_opt_t menu_opts[] =
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE), CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
CFG_INT((char *) "x", 0xffffffff, CFGF_NONE), CFG_INT((char *) "x", 0xffffffff, CFGF_NONE),
CFG_STR((char *) "font", NULL, CFGF_NONE), CFG_STR((char *) "font", NULL, CFGF_NONE),
CFG_SEC((char *) "colors", menu_colors_opts, CFGF_NONE), CFG_SEC((char *) "colors", screen_colors_opts, CFGF_NONE),
CFG_AWESOME_END() CFG_AWESOME_END()
}; };
cfg_opt_t awesome_opts[] = cfg_opt_t awesome_opts[] =

View File

@ -657,6 +657,9 @@ draw_color_new(Display *disp, int phys_screen, const char *colstr, XColor *color
Bool ret; Bool ret;
XColor exactColor; XColor exactColor;
if(!a_strlen(colstr))
return False;
if(!(ret = XAllocNamedColor(disp, if(!(ret = XAllocNamedColor(disp,
DefaultColormap(disp, phys_screen), DefaultColormap(disp, phys_screen),
colstr, colstr,
@ -667,6 +670,25 @@ draw_color_new(Display *disp, int phys_screen, const char *colstr, XColor *color
return ret; return ret;
} }
void
draw_colors_ctx_init(Display *disp, int phys_screen, cfg_t *cfg_colors,
colors_ctx_t *c, colors_ctx_t *m)
{
if(m)
*c = *m;
draw_color_new(disp, phys_screen,
cfg_getstr(cfg_colors, "fg"), &c->fg);
draw_color_new(disp, phys_screen,
cfg_getstr(cfg_colors, "bg"), &c->bg);
draw_color_new(disp, phys_screen,
cfg_getstr(cfg_colors, "border"), &c->border);
draw_color_new(disp, phys_screen,
cfg_getstr(cfg_colors, "shadow"), &c->shadow);
c->shadow_offset = cfg_getint(cfg_colors, "shadow_offset");
}
/** Remove a area from a list of them, /** Remove a area from a list of them,
* spliting the space between several area that can overlaps * spliting the space between several area that can overlaps
* \param head list head * \param head list head

View File

@ -23,6 +23,9 @@
#define AWESOME_COMMON_DRAW_H #define AWESOME_COMMON_DRAW_H
#include <cairo.h> #include <cairo.h>
#include <confuse.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
@ -123,6 +126,7 @@ Drawable draw_rotate(DrawCtx *, int, double, int, int);
unsigned short draw_textwidth(Display *, XftFont *, char *); unsigned short draw_textwidth(Display *, XftFont *, char *);
Alignment draw_get_align(const char *); Alignment draw_get_align(const char *);
Bool draw_color_new(Display *, int, const char *, XColor *); Bool draw_color_new(Display *, int, const char *, XColor *);
void draw_colors_ctx_init(Display *, int, cfg_t *, colors_ctx_t *, colors_ctx_t *);
void area_list_remove(Area **, Area *); void area_list_remove(Area **, Area *);

View File

@ -282,7 +282,8 @@ config_parse_screen(cfg_t *cfg, int screen)
Tag *tag = NULL; Tag *tag = NULL;
Statusbar *statusbar = NULL; Statusbar *statusbar = NULL;
cfg_t *cfg_general, *cfg_colors, *cfg_screen, *cfg_tags, cfg_t *cfg_general, *cfg_colors, *cfg_screen, *cfg_tags,
*cfg_layouts, *cfg_padding, *cfgsectmp; *cfg_layouts, *cfg_padding, *cfgsectmp,
*cfg_colors_normal, *cfg_colors_focus, *cfg_colors_urgent;
VirtScreen *virtscreen = &globalconf.screens[screen]; VirtScreen *virtscreen = &globalconf.screens[screen];
int i, phys_screen = get_phys_screen(screen); int i, phys_screen = get_phys_screen(screen);
@ -318,10 +319,6 @@ config_parse_screen(cfg_t *cfg, int screen)
virtscreen->font = XftFontOpenName(globalconf.display, virtscreen->font = XftFontOpenName(globalconf.display,
phys_screen, phys_screen,
cfg_getstr(cfg_general, "font")); cfg_getstr(cfg_general, "font"));
virtscreen->colors.normal.shadow_offset =
virtscreen->colors.focus.shadow_offset =
virtscreen->colors.urgent.shadow_offset =
cfg_getint(cfg_general, "text_shadow_offset");
virtscreen->floating_placement = virtscreen->floating_placement =
name_func_lookup(cfg_getstr(cfg_general, "floating_placement"), name_func_lookup(cfg_getstr(cfg_general, "floating_placement"),
FloatingPlacementList); FloatingPlacementList);
@ -360,30 +357,16 @@ config_parse_screen(cfg_t *cfg, int screen)
eprint("awesome: cannot init font\n"); eprint("awesome: cannot init font\n");
/* Colors */ /* Colors */
draw_color_new(globalconf.display, phys_screen, cfg_colors_normal = cfg_getsec(cfg_colors, "normal");
cfg_getstr(cfg_colors, "normal_border"), cfg_colors_focus = cfg_getsec(cfg_colors, "focus");
&virtscreen->colors.normal.border); cfg_colors_urgent = cfg_getsec(cfg_colors, "urgent");
draw_color_new(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "normal_bg"), draw_colors_ctx_init(globalconf.display, phys_screen,
&virtscreen->colors.normal.bg); cfg_colors_normal, &virtscreen->colors.normal, NULL);
draw_color_new(globalconf.display, phys_screen, draw_colors_ctx_init(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "normal_fg"), cfg_colors_focus, &virtscreen->colors.focus, NULL);
&virtscreen->colors.normal.fg); draw_colors_ctx_init(globalconf.display, phys_screen,
draw_color_new(globalconf.display, phys_screen, cfg_colors_urgent, &virtscreen->colors.urgent, NULL);
cfg_getstr(cfg_colors, "focus_border"),
&virtscreen->colors.focus.border);
draw_color_new(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "focus_bg"),
&virtscreen->colors.focus.bg);
draw_color_new(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "focus_fg"),
&virtscreen->colors.focus.fg);
draw_color_new(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "urgent_bg"),
&virtscreen->colors.urgent.bg);
draw_color_new(globalconf.display, phys_screen,
cfg_getstr(cfg_colors, "urgent_fg"),
&virtscreen->colors.urgent.fg);
/* Statusbar */ /* Statusbar */

View File

@ -268,6 +268,7 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
Widget *w; Widget *w;
Data *d; Data *d;
char *buf; char *buf;
cfg_t *cfg_colors;
int phys_screen = get_phys_screen(statusbar->screen); int phys_screen = get_phys_screen(statusbar->screen);
w = p_new(Widget, 1); w = p_new(Widget, 1);
@ -277,25 +278,17 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
w->alignment = AlignFlex; w->alignment = AlignFlex;
w->data = d = p_new(Data, 1); w->data = d = p_new(Data, 1);
if((buf = cfg_getstr(config, "fg"))) cfg_colors = cfg_getsec(config, "colors");
draw_color_new(globalconf.display, phys_screen, buf, &d->colors.normal.fg);
else
d->colors.normal.fg = globalconf.screens[statusbar->screen].colors.normal.fg;
if((buf = cfg_getstr(config, "bg"))) draw_colors_ctx_init(globalconf.display, phys_screen,
draw_color_new(globalconf.display, phys_screen, buf, &d->colors.normal.bg); cfg_getsec(cfg_colors, "normal"),
else &d->colors.normal,
d->colors.normal.bg = globalconf.screens[statusbar->screen].colors.normal.bg; &globalconf.screens[statusbar->screen].colors.normal);
if((buf = cfg_getstr(config, "focus_bg"))) draw_colors_ctx_init(globalconf.display, phys_screen,
draw_color_new(globalconf.display, phys_screen, buf, &d->colors.focus.bg); cfg_getsec(cfg_colors, "focus"),
else &d->colors.focus,
d->colors.focus.bg = globalconf.screens[statusbar->screen].colors.focus.bg; &globalconf.screens[statusbar->screen].colors.focus);
if((buf = cfg_getstr(config, "focus_fg")))
draw_color_new(globalconf.display, phys_screen, buf, &d->colors.focus.fg);
else
d->colors.focus.fg = globalconf.screens[statusbar->screen].colors.focus.fg;
d->align = draw_get_align(cfg_getstr(config, "text_align")); d->align = draw_get_align(cfg_getstr(config, "text_align"));
d->show_icons = cfg_getbool(config, "show_icons"); d->show_icons = cfg_getbool(config, "show_icons");

View File

@ -114,6 +114,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
Widget *w; Widget *w;
Data *d; Data *d;
char *buf; char *buf;
int phys_screen = get_phys_screen(statusbar->screen);
w = p_new(Widget, 1); w = p_new(Widget, 1);
widget_common_new(w, statusbar, config); widget_common_new(w, statusbar, config);
@ -123,21 +124,16 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
w->data = d = p_new(Data, 1); w->data = d = p_new(Data, 1);
if((buf = cfg_getstr(config, "fg"))) draw_colors_ctx_init(globalconf.display, phys_screen,
draw_color_new(globalconf.display, get_phys_screen(statusbar->screen), buf, &d->colors.fg); cfg_getsec(config, "colors"),
else &d->colors,
d->colors.fg = globalconf.screens[statusbar->screen].colors.normal.fg; &globalconf.screens[statusbar->screen].colors.normal);
if((buf = cfg_getstr(config, "bg")))
draw_color_new(globalconf.display, get_phys_screen(statusbar->screen), buf, &d->colors.bg);
else
d->colors.bg = globalconf.screens[statusbar->screen].colors.normal.bg;
d->width = cfg_getint(config, "width"); d->width = cfg_getint(config, "width");
d->align = draw_get_align(cfg_getstr(config, "text_align")); d->align = draw_get_align(cfg_getstr(config, "text_align"));
if((buf = cfg_getstr(config, "font"))) if((buf = cfg_getstr(config, "font")))
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf); w->font = XftFontOpenName(globalconf.display, phys_screen, buf);
if(!w->font) if(!w->font)
w->font = globalconf.screens[statusbar->screen].font; w->font = globalconf.screens[statusbar->screen].font;