add support for fg/bg colors and dedicated font for focustitle widget
This commit is contained in:
parent
360d9023a4
commit
bf5d5fa17e
6
config.c
6
config.c
|
@ -514,7 +514,7 @@ config_parse(const char *confpatharg)
|
||||||
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "image", (char *) NULL, CFGF_NONE),
|
||||||
CFG_END()
|
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_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
|
||||||
|
@ -534,9 +534,9 @@ config_parse(const char *confpatharg)
|
||||||
static cfg_opt_t statusbar_opts[] =
|
static cfg_opt_t statusbar_opts[] =
|
||||||
{
|
{
|
||||||
CFG_STR((char *) "position", (char *) "top", CFGF_NONE),
|
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 *) "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 *) "layoutinfo", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
||||||
CFG_SEC((char *) "iconbox", widget_iconbox_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),
|
CFG_SEC((char *) "netwmicon", widget_opts, CFGF_TITLE | CFGF_MULTI),
|
||||||
|
|
|
@ -27,13 +27,21 @@
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
|
#include "xutil.h"
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
XColor fg;
|
||||||
|
XColor bg;
|
||||||
|
} Data;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
{
|
{
|
||||||
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
||||||
|
Data *d = widget->data;
|
||||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
||||||
|
|
||||||
widget->location = widget_calculate_offset(vscreen.statusbar->width,
|
widget->location = widget_calculate_offset(vscreen.statusbar->width,
|
||||||
|
@ -44,20 +52,17 @@ focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
if(sel)
|
if(sel)
|
||||||
{
|
{
|
||||||
draw_text(ctx, widget->location, 0, vscreen.statusbar->width - used,
|
draw_text(ctx, widget->location, 0, vscreen.statusbar->width - used,
|
||||||
vscreen.statusbar->height, vscreen.font, sel->name,
|
vscreen.statusbar->height, widget->font, sel->name,
|
||||||
vscreen.colors_selected[ColFG],
|
d->fg, d->bg);
|
||||||
vscreen.colors_selected[ColBG]);
|
|
||||||
if(sel->isfloating)
|
if(sel->isfloating)
|
||||||
draw_circle(ctx, widget->location, 0,
|
draw_circle(ctx, widget->location, 0,
|
||||||
(vscreen.font->height + 2) / 4,
|
(widget->font->height + 2) / 4,
|
||||||
sel->ismax,
|
sel->ismax, d->fg);
|
||||||
vscreen.colors_selected[ColFG]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
draw_text(ctx, widget->location, 0, vscreen.statusbar->width - used,
|
draw_text(ctx, widget->location, 0, vscreen.statusbar->width - used,
|
||||||
vscreen.statusbar->height, vscreen.font, NULL,
|
vscreen.statusbar->height, widget->font, NULL,
|
||||||
vscreen.colors_normal[ColFG],
|
d->fg, d->bg);
|
||||||
vscreen.colors_normal[ColBG]);
|
|
||||||
|
|
||||||
widget->width = vscreen.statusbar->width - used;
|
widget->width = vscreen.statusbar->width - used;
|
||||||
|
|
||||||
|
@ -68,10 +73,31 @@ Widget *
|
||||||
focustitle_new(Statusbar *statusbar, cfg_t *config)
|
focustitle_new(Statusbar *statusbar, cfg_t *config)
|
||||||
{
|
{
|
||||||
Widget *w;
|
Widget *w;
|
||||||
|
Data *d;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
w = p_new(Widget, 1);
|
w = p_new(Widget, 1);
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
w->draw = focustitle_draw;
|
w->draw = focustitle_draw;
|
||||||
w->alignment = AlignFlex;
|
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;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue