Add support for styles in titlebar
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
21277ad12b
commit
2aebe166c7
|
@ -155,27 +155,6 @@ cfg_getposition(cfg_t *cfg, const char *name)
|
|||
return cfg_getnposition(cfg, name, 0);
|
||||
}
|
||||
|
||||
cfg_opt_t titlebar_opts[] =
|
||||
{
|
||||
CFG_POSITION((char *) "position", (char *) "auto", CFGF_NONE),
|
||||
CFG_ALIGNMENT((char *) "text_align", (char *) "center", CFGF_NONE),
|
||||
CFG_AWESOME_END()
|
||||
};
|
||||
cfg_opt_t general_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "border", 1, CFGF_NONE),
|
||||
CFG_INT((char *) "snap", 8, CFGF_NONE),
|
||||
CFG_BOOL((char *) "resize_hints", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "sloppy_focus", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "sloppy_focus_raise", cfg_false, CFGF_NONE),
|
||||
CFG_BOOL((char *) "new_become_master", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "new_get_focus", cfg_true, CFGF_NONE),
|
||||
CFG_INT((char *) "opacity_unfocused", -1, CFGF_NONE),
|
||||
CFG_STR((char *) "floating_placement", (char *) "smart", CFGF_NONE),
|
||||
CFG_FLOAT((char *) "mwfact_lower_limit", 0.1, CFGF_NONE),
|
||||
CFG_FLOAT((char *) "mwfact_upper_limit", 0.9, CFGF_NONE),
|
||||
CFG_AWESOME_END()
|
||||
};
|
||||
cfg_opt_t style_opts[] =
|
||||
{
|
||||
CFG_STR((char *) "border", NULL, CFGF_NONE),
|
||||
|
@ -193,6 +172,28 @@ cfg_opt_t styles_opts[] =
|
|||
CFG_SEC((char *) "urgent", style_opts, CFGF_NONE),
|
||||
CFG_AWESOME_END()
|
||||
};
|
||||
cfg_opt_t titlebar_opts[] =
|
||||
{
|
||||
CFG_POSITION((char *) "position", (char *) "auto", CFGF_NONE),
|
||||
CFG_ALIGNMENT((char *) "text_align", (char *) "center", CFGF_NONE),
|
||||
CFG_SEC((char *) "styles", styles_opts, CFGF_NONE),
|
||||
CFG_AWESOME_END()
|
||||
};
|
||||
cfg_opt_t general_opts[] =
|
||||
{
|
||||
CFG_INT((char *) "border", 1, CFGF_NONE),
|
||||
CFG_INT((char *) "snap", 8, CFGF_NONE),
|
||||
CFG_BOOL((char *) "resize_hints", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "sloppy_focus", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "sloppy_focus_raise", cfg_false, CFGF_NONE),
|
||||
CFG_BOOL((char *) "new_become_master", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "new_get_focus", cfg_true, CFGF_NONE),
|
||||
CFG_INT((char *) "opacity_unfocused", -1, CFGF_NONE),
|
||||
CFG_STR((char *) "floating_placement", (char *) "smart", CFGF_NONE),
|
||||
CFG_FLOAT((char *) "mwfact_lower_limit", 0.1, CFGF_NONE),
|
||||
CFG_FLOAT((char *) "mwfact_upper_limit", 0.9, CFGF_NONE),
|
||||
CFG_AWESOME_END()
|
||||
};
|
||||
cfg_opt_t mouse_taglist_opts[] =
|
||||
{
|
||||
CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE),
|
||||
|
|
27
config.c
27
config.c
|
@ -266,7 +266,8 @@ statusbar_widgets_create(cfg_t *cfg_statusbar, Statusbar *statusbar)
|
|||
{
|
||||
widget = widget_new(statusbar, wptr);
|
||||
widget_list_append(&statusbar->widgets, widget);
|
||||
widget->buttons = parse_mouse_bindings(wptr, "mouse", a_strcmp(cfg_name(wptr), "taglist") ? True : False);
|
||||
widget->buttons = parse_mouse_bindings(wptr, "mouse",
|
||||
a_strcmp(cfg_name(wptr), "taglist") ? True : False);
|
||||
}
|
||||
else
|
||||
warn("ignoring unknown widget: %s.\n", cfg_name(widgets + i));
|
||||
|
@ -274,10 +275,25 @@ statusbar_widgets_create(cfg_t *cfg_statusbar, Statusbar *statusbar)
|
|||
}
|
||||
|
||||
static void
|
||||
config_section_titlebar_init(cfg_t *cfg_titlebar, Titlebar *tb)
|
||||
config_section_titlebar_init(cfg_t *cfg_titlebar, Titlebar *tb, int screen)
|
||||
{
|
||||
int phys_screen = get_phys_screen(screen);
|
||||
cfg_t *cfg_styles = cfg_getsec(cfg_titlebar, "styles");
|
||||
|
||||
tb->position = tb->dposition = cfg_getposition(cfg_titlebar, "position");
|
||||
tb->text_align = cfg_getalignment(cfg_titlebar, "text_align");
|
||||
draw_style_init(globalconf.display, phys_screen,
|
||||
cfg_getsec(cfg_styles, "normal"),
|
||||
&tb->styles.normal,
|
||||
&globalconf.screens[screen].styles.normal);
|
||||
draw_style_init(globalconf.display, phys_screen,
|
||||
cfg_getsec(cfg_styles, "focus"),
|
||||
&tb->styles.focus,
|
||||
&globalconf.screens[screen].styles.focus);
|
||||
draw_style_init(globalconf.display, phys_screen,
|
||||
cfg_getsec(cfg_styles, "urgent"),
|
||||
&tb->styles.urgent,
|
||||
&globalconf.screens[screen].styles.urgent);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -328,8 +344,6 @@ config_parse_screen(cfg_t *cfg, int screen)
|
|||
virtscreen->floating_placement =
|
||||
name_func_lookup(cfg_getstr(cfg_general, "floating_placement"),
|
||||
FloatingPlacementList);
|
||||
config_section_titlebar_init(cfg_titlebar, &virtscreen->titlebar_default);
|
||||
|
||||
virtscreen->mwfact_lower_limit = cfg_getfloat(cfg_general, "mwfact_lower_limit");
|
||||
virtscreen->mwfact_upper_limit = cfg_getfloat(cfg_general, "mwfact_upper_limit");
|
||||
|
||||
|
@ -367,6 +381,9 @@ config_parse_screen(cfg_t *cfg, int screen)
|
|||
if(!virtscreen->styles.normal.font)
|
||||
eprint("no font available\n");
|
||||
|
||||
/* Titlebar */
|
||||
config_section_titlebar_init(cfg_titlebar, &virtscreen->titlebar_default, screen);
|
||||
|
||||
/* Statusbar */
|
||||
statusbar_list_init(&virtscreen->statusbar);
|
||||
for(i = cfg_size(cfg_screen, "statusbar") - 1; i >= 0; i--)
|
||||
|
@ -521,7 +538,7 @@ config_parse(const char *confpatharg)
|
|||
rule->screen = cfg_getint(cfgsectmp, "screen");
|
||||
rule->ismaster = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "master"));
|
||||
rule->opacity = cfg_getfloat(cfgsectmp, "opacity");
|
||||
config_section_titlebar_init(cfg_getsec(cfgsectmp, "titlebar"), &rule->titlebar);
|
||||
config_section_titlebar_init(cfg_getsec(cfgsectmp, "titlebar"), &rule->titlebar, 0);
|
||||
if(rule->screen >= globalconf.screens_info->nscreen)
|
||||
rule->screen = 0;
|
||||
|
||||
|
|
|
@ -46,6 +46,13 @@ typedef struct
|
|||
Position position;
|
||||
Position dposition;
|
||||
Alignment text_align;
|
||||
/** Colors */
|
||||
struct
|
||||
{
|
||||
style_t normal;
|
||||
style_t focus;
|
||||
style_t urgent;
|
||||
} styles;
|
||||
} Titlebar;
|
||||
|
||||
/** Rule type */
|
||||
|
|
24
titlebar.c
24
titlebar.c
|
@ -29,11 +29,20 @@ extern AwesomeConf globalconf;
|
|||
void
|
||||
titlebar_init(Client *c)
|
||||
{
|
||||
int titlebar_height = 1.5 * MAX(globalconf.screens[c->screen].styles.normal.font->height,
|
||||
MAX(globalconf.screens[c->screen].styles.focus.font->height,
|
||||
globalconf.screens[c->screen].styles.urgent.font->height));
|
||||
int titlebar_height;
|
||||
int phys_screen = get_phys_screen(c->screen);
|
||||
|
||||
if(c->titlebar.position == Off
|
||||
|| c->titlebar.position == Auto)
|
||||
{
|
||||
c->titlebar.position = Off;
|
||||
return;
|
||||
}
|
||||
|
||||
titlebar_height = 1.5 * MAX(c->titlebar.styles.normal.font->height,
|
||||
MAX(c->titlebar.styles.focus.font->height,
|
||||
c->titlebar.styles.urgent.font->height));
|
||||
|
||||
switch(c->titlebar.position)
|
||||
{
|
||||
case Top:
|
||||
|
@ -72,10 +81,7 @@ titlebar_init(Client *c)
|
|||
c->geometry.width + 2 * c->border,
|
||||
0);
|
||||
break;
|
||||
case Off:
|
||||
break;
|
||||
default:
|
||||
c->titlebar.position = Off;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -120,11 +126,11 @@ titlebar_update(Client *c)
|
|||
|
||||
|
||||
if(c->isurgent)
|
||||
style = globalconf.screens[c->screen].styles.urgent;
|
||||
style = c->titlebar.styles.urgent;
|
||||
else if(globalconf.focus->client == c)
|
||||
style = globalconf.screens[c->screen].styles.focus;
|
||||
style = c->titlebar.styles.focus;
|
||||
else
|
||||
style = globalconf.screens[c->screen].styles.normal;
|
||||
style = c->titlebar.styles.normal;
|
||||
|
||||
geometry.x = geometry.y = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue