add support for fg/bg colors and dedicated font for focustitle widget

This commit is contained in:
Julien Danjou 2007-12-29 19:39:46 +01:00
parent 360d9023a4
commit bf5d5fa17e
2 changed files with 38 additions and 12 deletions

View File

@ -514,7 +514,7 @@ config_parse(const char *confpatharg)
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
CFG_END()
};
static cfg_opt_t widget_textbox_opts[] =
static cfg_opt_t widget_textbox_focus_opts[] =
{
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
@ -534,9 +534,9 @@ config_parse(const char *confpatharg)
static cfg_opt_t statusbar_opts[] =
{
CFG_STR((char *) "position", (char *) "top", CFGF_NONE),
CFG_SEC((char *) "textbox", widget_textbox_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "textbox", widget_textbox_focus_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "taglist", widget_taglist_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "focustitle", widget_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "focustitle", widget_textbox_focus_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "layoutinfo", widget_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "iconbox", widget_iconbox_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC((char *) "netwmicon", widget_opts, CFGF_TITLE | CFGF_MULTI),

View File

@ -27,13 +27,21 @@
#include "layout.h"
#include "tag.h"
#include "focus.h"
#include "xutil.h"
extern AwesomeConf globalconf;
typedef struct
{
XColor fg;
XColor bg;
} Data;
static int
focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
{
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
Data *d = widget->data;
Client *sel = focus_get_current_client(widget->statusbar->screen);
widget->location = widget_calculate_offset(vscreen.statusbar->width,
@ -44,20 +52,17 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
if(sel)
{
draw_text(ctx, widget->location, 0, vscreen.statusbar->width - used,
vscreen.statusbar->height, vscreen.font, sel->name,
vscreen.colors_selected[ColFG],
vscreen.colors_selected[ColBG]);
vscreen.statusbar->height, widget->font, sel->name,
d->fg, d->bg);
if(sel->isfloating)
draw_circle(ctx, widget->location, 0,
(vscreen.font->height + 2) / 4,
sel->ismax,
vscreen.colors_selected[ColFG]);
(widget->font->height + 2) / 4,
sel->ismax, d->fg);
}
else
draw_text(ctx, widget->location, 0, vscreen.statusbar->width - used,
vscreen.statusbar->height, vscreen.font, NULL,
vscreen.colors_normal[ColFG],
vscreen.colors_normal[ColBG]);
vscreen.statusbar->height, widget->font, NULL,
d->fg, d->bg);
widget->width = vscreen.statusbar->width - used;
@ -68,10 +73,31 @@ Widget *
focustitle_new(Statusbar *statusbar, cfg_t *config)
{
Widget *w;
Data *d;
char *buf;
w = p_new(Widget, 1);
widget_common_new(w, statusbar, config);
w->draw = focustitle_draw;
w->alignment = AlignFlex;
w->data = d = p_new(Data, 1);
if((buf = cfg_getstr(config, "fg")))
d->fg = initxcolor(statusbar->screen, buf);
else
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG];
if((buf = cfg_getstr(config, "bg")))
d->fg = initxcolor(statusbar->screen, buf);
else
d->fg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
if((buf = cfg_getstr(config, "font")))
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);
if(!w->font)
w->font = globalconf.screens[statusbar->screen].font;
return w;
}