Titlebar/Stipple: Add option stipple_{normal, focus} to choose stipple color.

This commit is contained in:
Martin Duquesnoy 2009-04-21 16:58:01 +02:00
parent 2b406a54c6
commit 5be5b19266
9 changed files with 40 additions and 23 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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));

View File

@ -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()
};

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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 {{{ */