[tasklist] Remove styles; use drawtext format
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
26621fd598
commit
eab7633675
16
client.c
16
client.c
|
@ -36,6 +36,7 @@
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "titlebar.h"
|
#include "titlebar.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
#include "common/markup.h"
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
#include "common/xscreen.h"
|
#include "common/xscreen.h"
|
||||||
|
|
||||||
|
@ -807,6 +808,21 @@ client_updatesizehints(client_t *c)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
client_markup_parse(client_t *c, const char *str, ssize_t len)
|
||||||
|
{
|
||||||
|
const char *elements[] = { "title", NULL };
|
||||||
|
const char *elements_sub[] = { c->name , NULL };
|
||||||
|
markup_parser_data_t *p;
|
||||||
|
|
||||||
|
p = markup_parser_data_new(elements, elements_sub, countof(elements));
|
||||||
|
|
||||||
|
if(!markup_parse(p, str, len))
|
||||||
|
return a_strdup(str);
|
||||||
|
|
||||||
|
return p->text;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set the transparency of the selected client.
|
/** Set the transparency of the selected client.
|
||||||
* Argument should be an absolut or relativ floating between 0.0 and 1.0
|
* Argument should be an absolut or relativ floating between 0.0 and 1.0
|
||||||
* \param screen Screen ID
|
* \param screen Screen ID
|
||||||
|
|
1
client.h
1
client.h
|
@ -42,6 +42,7 @@ void client_updatetitle(client_t *);
|
||||||
void client_saveprops(client_t *);
|
void client_saveprops(client_t *);
|
||||||
void client_kill(client_t *);
|
void client_kill(client_t *);
|
||||||
void client_setfloating(client_t *, bool, layer_t);
|
void client_setfloating(client_t *, bool, layer_t);
|
||||||
|
char * client_markup_parse(client_t *, const char *, ssize_t);
|
||||||
|
|
||||||
uicb_t uicb_client_kill;
|
uicb_t uicb_client_kill;
|
||||||
uicb_t uicb_client_moveresize;
|
uicb_t uicb_client_moveresize;
|
||||||
|
|
|
@ -328,8 +328,12 @@ cfg_opt_t widget_tasklist_opts[] =
|
||||||
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
CFG_INT((char *) "y", 0xffffffff, CFGF_NONE),
|
||||||
/** Mouse bindings. */
|
/** Mouse bindings. */
|
||||||
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
|
||||||
/** Styles to use for drawing. */
|
/** Markup title string for normal window */
|
||||||
CFG_SEC((char *) "styles", styles_opts, CFGF_NONE),
|
CFG_STR((char *) "text_normal", (char *) "<bg color=\"#444444\"/><title/>", CFGF_NONE),
|
||||||
|
/** Markup title string for focused windows. */
|
||||||
|
CFG_STR((char *) "text_focus", (char *) "<bg color=\"#535d6c\"/><title/>", CFGF_NONE),
|
||||||
|
/** Markup title string for urgent windows. */
|
||||||
|
CFG_STR((char *) "text_urgent", (char *) "<bg color=\"#ff4500\"/><title/>", CFGF_NONE),
|
||||||
/** Text alignment. */
|
/** Text alignment. */
|
||||||
CFG_ALIGNMENT((char *) "text_align", (char *) "left", CFGF_NONE),
|
CFG_ALIGNMENT((char *) "text_align", (char *) "left", CFGF_NONE),
|
||||||
/** Which windows to show: tags, all or focus. */
|
/** Which windows to show: tags, all or focus. */
|
||||||
|
|
18
titlebar.c
18
titlebar.c
|
@ -27,25 +27,9 @@
|
||||||
#include "titlebar.h"
|
#include "titlebar.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
#include "common/markup.h"
|
|
||||||
|
|
||||||
extern AwesomeConf globalconf;
|
extern AwesomeConf globalconf;
|
||||||
|
|
||||||
static char *
|
|
||||||
titlebar_markup_parse(client_t *c, const char *str, ssize_t len)
|
|
||||||
{
|
|
||||||
const char *elements[] = { "title", NULL };
|
|
||||||
const char *elements_sub[] = { c->name , NULL };
|
|
||||||
markup_parser_data_t *p;
|
|
||||||
|
|
||||||
p = markup_parser_data_new(elements, elements_sub, countof(elements));
|
|
||||||
|
|
||||||
if(!markup_parse(p, str, len))
|
|
||||||
return a_strdup(str);
|
|
||||||
|
|
||||||
return p->text;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
titlebar_text(client_t *c)
|
titlebar_text(client_t *c)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +42,7 @@ titlebar_text(client_t *c)
|
||||||
else
|
else
|
||||||
text = c->titlebar.text_normal;
|
text = c->titlebar.text_normal;
|
||||||
|
|
||||||
return titlebar_markup_parse(c, text, a_strlen(text));
|
return client_markup_parse(c, text, a_strlen(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline area_t
|
static inline area_t
|
||||||
|
|
|
@ -44,12 +44,7 @@ typedef struct
|
||||||
Showclient_t show;
|
Showclient_t show;
|
||||||
bool show_icons;
|
bool show_icons;
|
||||||
alignment_t align;
|
alignment_t align;
|
||||||
struct
|
char *text_normal, *text_urgent, *text_focus;
|
||||||
{
|
|
||||||
style_t normal;
|
|
||||||
style_t focus;
|
|
||||||
style_t urgent;
|
|
||||||
} styles;
|
|
||||||
} Data;
|
} Data;
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
@ -77,9 +72,10 @@ tasklist_draw(widget_t *widget, DrawCtx *ctx, int offset, int used)
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
rule_t *r;
|
rule_t *r;
|
||||||
area_t area;
|
area_t area;
|
||||||
style_t style;
|
char *text;
|
||||||
int n = 0, i = 0, box_width = 0, icon_width = 0, box_width_rest = 0;
|
int n = 0, i = 0, box_width = 0, icon_width = 0, box_width_rest = 0;
|
||||||
NetWMIcon *icon;
|
NetWMIcon *icon;
|
||||||
|
style_t style;
|
||||||
|
|
||||||
if(used >= widget->statusbar->width)
|
if(used >= widget->statusbar->width)
|
||||||
return (widget->area.width = 0);
|
return (widget->area.width = 0);
|
||||||
|
@ -110,11 +106,22 @@ tasklist_draw(widget_t *widget, DrawCtx *ctx, int offset, int used)
|
||||||
icon_width = 0;
|
icon_width = 0;
|
||||||
|
|
||||||
if(c->isurgent)
|
if(c->isurgent)
|
||||||
style = d->styles.urgent;
|
{
|
||||||
|
text = d->text_urgent;
|
||||||
|
style = globalconf.screens[c->screen].styles.urgent;
|
||||||
|
}
|
||||||
else if(globalconf.focus->client == c)
|
else if(globalconf.focus->client == c)
|
||||||
style = d->styles.focus;
|
{
|
||||||
|
text = d->text_focus;
|
||||||
|
style = globalconf.screens[c->screen].styles.focus;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
style = d->styles.normal;
|
{
|
||||||
|
text = d->text_normal;
|
||||||
|
style = globalconf.screens[c->screen].styles.normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
text = client_markup_parse(c, text, a_strlen(text));
|
||||||
|
|
||||||
if(d->show_icons)
|
if(d->show_icons)
|
||||||
{
|
{
|
||||||
|
@ -164,9 +171,11 @@ tasklist_draw(widget_t *widget, DrawCtx *ctx, int offset, int used)
|
||||||
area.width += box_width_rest;
|
area.width += box_width_rest;
|
||||||
|
|
||||||
draw_text(ctx, area, d->align,
|
draw_text(ctx, area, d->align,
|
||||||
style.font->height / 2, c->name,
|
style.font->height / 2, text,
|
||||||
style);
|
style);
|
||||||
|
|
||||||
|
p_delete(&text);
|
||||||
|
|
||||||
if(c == globalconf.scratch.client)
|
if(c == globalconf.scratch.client)
|
||||||
{
|
{
|
||||||
area.x = widget->area.x + icon_width + box_width * i;
|
area.x = widget->area.x + icon_width + box_width * i;
|
||||||
|
@ -263,7 +272,6 @@ tasklist_new(statusbar_t *statusbar, cfg_t *config)
|
||||||
widget_t *w;
|
widget_t *w;
|
||||||
Data *d;
|
Data *d;
|
||||||
char *buf;
|
char *buf;
|
||||||
cfg_t *cfg_styles;
|
|
||||||
|
|
||||||
w = p_new(widget_t, 1);
|
w = p_new(widget_t, 1);
|
||||||
widget_common_new(w, statusbar, config);
|
widget_common_new(w, statusbar, config);
|
||||||
|
@ -272,23 +280,9 @@ tasklist_new(statusbar_t *statusbar, cfg_t *config)
|
||||||
w->alignment = AlignFlex;
|
w->alignment = AlignFlex;
|
||||||
w->data = d = p_new(Data, 1);
|
w->data = d = p_new(Data, 1);
|
||||||
|
|
||||||
cfg_styles = cfg_getsec(config, "styles");
|
d->text_normal = a_strdup(cfg_getstr(config, "text_normal"));
|
||||||
|
d->text_focus = a_strdup(cfg_getstr(config, "text_focus"));
|
||||||
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
d->text_urgent = a_strdup(cfg_getstr(config, "text_urgent"));
|
||||||
cfg_getsec(cfg_styles, "normal"),
|
|
||||||
&d->styles.normal,
|
|
||||||
&globalconf.screens[statusbar->screen].styles.normal);
|
|
||||||
|
|
||||||
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
|
||||||
cfg_getsec(cfg_styles, "focus"),
|
|
||||||
&d->styles.focus,
|
|
||||||
&globalconf.screens[statusbar->screen].styles.focus);
|
|
||||||
|
|
||||||
draw_style_init(globalconf.connection, statusbar->phys_screen,
|
|
||||||
cfg_getsec(cfg_styles, "urgent"),
|
|
||||||
&d->styles.urgent,
|
|
||||||
&globalconf.screens[statusbar->screen].styles.urgent);
|
|
||||||
|
|
||||||
d->align = cfg_getalignment(config, "text_align");
|
d->align = cfg_getalignment(config, "text_align");
|
||||||
d->show_icons = cfg_getbool(config, "show_icons");
|
d->show_icons = cfg_getbool(config, "show_icons");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue