diff --git a/src/barwin.c b/src/barwin.c index f726b80..b543491 100644 --- a/src/barwin.c +++ b/src/barwin.c @@ -265,7 +265,7 @@ barwin_refresh_color(BarWindow *bw) if(bw->stipple) { - XSetForeground(dpy, gc_stipple, getcolor(bw->fg)); + XSetForeground(dpy, gc_stipple, ((bw->stipple_color) ? bw->stipple_color : getcolor(bw->fg))); XFillRectangle(dpy, bw->dr, gc_stipple, 3, 2, bw->geo.width - 6, bw->geo.height - 4); } diff --git a/src/client.c b/src/client.c index 2e4af95..4113a0a 100644 --- a/src/client.c +++ b/src/client.c @@ -146,6 +146,8 @@ client_focus(Client *c) sel->colors.frame = conf.client.bordernormal; sel->colors.fg = conf.titlebar.fg_normal; sel->colors.resizecorner = conf.client.resizecorner_normal; + if(TBARH - BORDH && sel->titlebar->stipple) + sel->titlebar->stipple_color = conf.titlebar.stipple.colors.normal; frame_update(sel); mouse_grabbuttons(sel, False); } @@ -157,6 +159,8 @@ client_focus(Client *c) c->colors.frame = conf.client.borderfocus; c->colors.fg = conf.titlebar.fg_focus; c->colors.resizecorner = conf.client.resizecorner_focus; + if(TBARH - BORDH && c->titlebar->stipple) + c->titlebar->stipple_color = conf.titlebar.stipple.colors.focus; frame_update(c); mouse_grabbuttons(c, True); if(conf.raisefocus) diff --git a/src/config.c b/src/config.c index 8a36850..b9b9d95 100644 --- a/src/config.c +++ b/src/config.c @@ -188,10 +188,22 @@ conf_client_section(cfg_t *cfg_c) /* Titlebar part {{ */ cfgtmp = cfg_getsec(cfg_c, "titlebar"); conf.titlebar.height = cfg_getint(cfgtmp, "height"); - conf.titlebar.stipple = cfg_getbool(cfgtmp, "stipple"); conf.titlebar.fg_normal = alias_to_str(cfg_getstr(cfgtmp, "fg_normal")); conf.titlebar.fg_focus = alias_to_str(cfg_getstr(cfgtmp, "fg_focus")); + /* Stipple */ + conf.titlebar.stipple.active = cfg_getbool(cfgtmp, "stipple"); + + if(!strcmp(alias_to_str(cfg_getstr(cfgtmp, "stipple_normal")), "-1")) + conf.titlebar.stipple.colors.normal = getcolor(conf.titlebar.fg_normal); + else + conf.titlebar.stipple.colors.normal = getcolor(alias_to_str(cfg_getstr(cfgtmp, "stipple_normal"))); + + if(!strcmp(alias_to_str(cfg_getstr(cfgtmp, "stipple_focus")), "-1")) + conf.titlebar.stipple.colors.focus = getcolor(conf.titlebar.fg_focus); + else + conf.titlebar.stipple.colors.focus = getcolor(alias_to_str(cfg_getstr(cfgtmp, "stipple_focus"))); + if((conf.titlebar.nmouse = cfg_size(cfgtmp, "mouse"))) { conf.titlebar.mouse = emalloc(conf.titlebar.nmouse, sizeof(MouseBinding)); diff --git a/src/config_struct.h b/src/config_struct.h index 5fe8e8b..87f0082 100644 --- a/src/config_struct.h +++ b/src/config_struct.h @@ -88,12 +88,14 @@ cfg_opt_t button_opts[] = cfg_opt_t titlebar_opts[] = { - CFG_INT("height", 0, CFGF_NONE), - CFG_BOOL("stipple", cfg_false, CFGF_NONE), - CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE), - CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE), - CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI), - CFG_SEC("button", button_opts, CFGF_MULTI), + CFG_INT("height", 0, CFGF_NONE), + CFG_BOOL("stipple", cfg_false, CFGF_NONE), + CFG_STR("stipple_normal", "-1", CFGF_NONE), + CFG_STR("stipple_focus", "-1", CFGF_NONE), + CFG_STR("fg_normal", "#FFFFFF", CFGF_NONE), + CFG_STR("fg_focus", "#FFFFFF", CFGF_NONE), + CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI), + CFG_SEC("button", button_opts, CFGF_MULTI), CFG_END() }; diff --git a/src/frame.c b/src/frame.c index dbcebad..62840b3 100644 --- a/src/frame.c +++ b/src/frame.c @@ -78,7 +78,7 @@ frame_create(Client *c) TBARH, c->colors.frame, c->colors.fg, - True, conf.titlebar.stipple, False); + True, conf.titlebar.stipple.active, False); /* Buttons */ if(BUTTONWH >= 1) @@ -205,7 +205,7 @@ frame_update(Client *c) /* Buttons */ if(conf.titlebar.nbutton && BUTTONWH >= 1) { - if(conf.titlebar.stipple) + if(conf.titlebar.stipple.active) draw_rectangle(c->titlebar->dr, 0, 0, c->button_last_x + TBARH - (TBARH / 4), TBARH + BORDH * 2, c->colors.frame); diff --git a/src/menu.c b/src/menu.c index f779d8d..362a649 100644 --- a/src/menu.c +++ b/src/menu.c @@ -184,16 +184,8 @@ menu_focus_item(Menu *menu, int item, BarWindow *winitem[]) for(i = 0; i < menu->nitem; ++i) { - if(i == menu->focus_item) - { - winitem[i]->fg = menu->colors.focus.fg; - winitem[i]->bg = menu->colors.focus.bg; - } - else - { - winitem[i]->fg = menu->colors.normal.fg; - winitem[i]->bg = menu->colors.normal.bg; - } + winitem[i]->fg = ((i == menu->focus_item) ? menu->colors.focus.fg : menu->colors.normal.fg); + winitem[i]->bg = ((i == menu->focus_item) ? menu->colors.focus.bg : menu->colors.normal.bg); barwin_refresh_color(winitem[i]); menu_draw_item_name(menu, i, winitem); diff --git a/src/structs.h b/src/structs.h index bfccf0a..830f31f 100644 --- a/src/structs.h +++ b/src/structs.h @@ -108,9 +108,11 @@ typedef struct Window left, right, top, bottom; /* Border color */ uint dark, light; + } border; uint bg; char *fg; + uint stipple_color; XRectangle geo; Bool mapped, stipple, bord; } BarWindow; @@ -316,7 +318,11 @@ typedef struct int height; char *fg_normal; char *fg_focus; - Bool stipple; + struct + { + Bool active; + struct { uint normal, focus; } colors; + } stipple; MouseBinding *mouse; int nmouse; Button *button; diff --git a/src/util.c b/src/util.c index 0ff456d..0a82e82 100644 --- a/src/util.c +++ b/src/util.c @@ -52,13 +52,14 @@ emalloc(uint element, uint size) * \param color Color string * \return Color pixel */ -ulong +long getcolor(char *color) { XColor xcolor; if(!XAllocNamedColor(dpy, DefaultColormap(dpy, SCREEN), color, &xcolor, &xcolor)) fprintf(stderr,"WMFS Error: cannot allocate color \"%s\"\n", color); + return xcolor.pixel; } diff --git a/src/wmfs.h b/src/wmfs.h index 1c670cf..9d7cf48 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -223,7 +223,7 @@ void uicb_mouse_resize(uicb_t); /* util.c */ ulong color_enlight(ulong col); void *emalloc(uint element, uint size); -ulong getcolor(char *color); +long getcolor(char *color); void setwinstate(Window win, long state); char* _strdup(char const *str); /* Conf usage {{{ */