Use section for titlebar parameters

This commit is contained in:
Julien Danjou 2008-03-14 20:35:24 +01:00
parent ece6ffb8fe
commit cc56ccd2e9
5 changed files with 51 additions and 19 deletions

View File

@ -45,7 +45,7 @@ general
General is a section containing some general options for this screen.
titlebar::
This option defines the position of window titlebar.
This section defines the parameters of the windows titlebar.
border::
This defines the window borders size in pixel.
font::
@ -537,10 +537,13 @@ Note: when there is no whitespace, quotes are optional.
<string> -> "foo bar"
<uicb-arg> -> prog, 3... (argument to a uicb function, where required)
<uicb-cmd> -> spawn, exec, client_tag... (see UICB FUNCTIONS above)
<position> -> list of position: off, top, right, left, bottom, auto
<{.., ...}> -> list of available options
<style section> -> a section with font, fg, bg, border, shadow and shadow_offset options.
{ font = <font> fg = <color> bg = <color> border = <color>
shadow = <color> shadow_offset = <integer> }
<titlebar> -> a section with position and icon position.
{ position = <position> icon = <position> }
[MULTI] means, you can use an item multiple times.
@ -562,6 +565,10 @@ screen <integer> [MULTI]
mwfact_lower_limit = <float>
mwfact_upper_limit = <float>
}
titlebar
{
<titlebar>
}
tags
{
tag <identifier> [MULTI]
@ -594,7 +601,7 @@ screen <integer> [MULTI]
}
statusbar <identifier> [MULTI]
{
position = <{top,bottom,left,right}>
position = <{top,bottom,left,right,off}>
height = <integer>
width = <integer>
@ -728,6 +735,10 @@ rules
screen = <integer>
icon = <image>
opacity = <float>
titlebar
{
<titlebar>
}
}
}
keys

View File

@ -358,7 +358,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
ewmh_check_client_hints(c);
/* default titlebar position */
c->titlebar.position = globalconf.screens[screen].titlebar_default_position;
c->titlebar.position = globalconf.screens[screen].titlebar_default.position;
/* First check clients hints */
ewmh_check_client_hints(c);
@ -393,8 +393,8 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
if(rule->opacity >= 0.0f)
window_settrans(c->win, rule->opacity);
if(rule->titlebar != Auto)
c->titlebar.position = rule->titlebar;
if(rule->titlebar.position != Auto)
c->titlebar.position = rule->titlebar.position;
}
else
move_client_to_screen(c, screen, True);

View File

@ -67,10 +67,15 @@ cfg_awesome_include(cfg_t *cfg, cfg_opt_t *opt,
return cfg_include(cfg, opt, argc, argv);
}
cfg_opt_t titlebar_opts[] =
{
CFG_STR((char *) "position", (char *) "off", CFGF_NONE),
CFG_STR((char *) "icon", (char *) "left", CFGF_NONE),
CFG_AWESOME_END()
};
cfg_opt_t general_opts[] =
{
CFG_INT((char *) "border", 1, CFGF_NONE),
CFG_STR((char *) "titlebar", (char *) "off", 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),
@ -264,6 +269,7 @@ cfg_opt_t padding_opts[] =
cfg_opt_t screen_opts[] =
{
CFG_SEC((char *) "general", general_opts, CFGF_NONE),
CFG_SEC((char *) "titlebar", titlebar_opts, CFGF_NONE),
CFG_SEC((char *) "statusbar", statusbar_opts, CFGF_TITLE | CFGF_MULTI | CFGF_NO_TITLE_DUPES),
CFG_SEC((char *) "tags", tags_opts, CFGF_NONE),
CFG_SEC((char *) "styles", styles_opts, CFGF_NONE),
@ -280,7 +286,7 @@ cfg_opt_t rule_opts[] =
CFG_STR((char *) "icon", NULL, CFGF_NONE),
CFG_STR((char *) "float", (char *) "auto", CFGF_NONE),
CFG_STR((char *) "master", (char *) "auto", CFGF_NONE),
CFG_STR((char *) "titlebar", (char *) "auto", CFGF_NONE),
CFG_SEC((char *) "titlebar", titlebar_opts, CFGF_NONE),
CFG_INT((char *) "screen", RULE_NOSCREEN, CFGF_NONE),
CFG_FLOAT((char *) "opacity", -1.0f, CFGF_NONE),
CFG_AWESOME_END()

View File

@ -272,6 +272,18 @@ create_widgets(cfg_t* cfg_statusbar, Statusbar *statusbar)
}
}
static void
config_section_titlebar_init(cfg_t *cfg_titlebar, Titlebar *tb)
{
if(cfg_titlebar)
{
tb->position = position_get_from_str(cfg_getstr(cfg_titlebar, "position"));
tb->icon = position_get_from_str(cfg_getstr(cfg_titlebar, "icon"));
}
else
tb->position = Auto;
}
static void
config_parse_screen(cfg_t *cfg, int screen)
{
@ -282,7 +294,7 @@ config_parse_screen(cfg_t *cfg, int screen)
Tag *tag = NULL;
Statusbar *statusbar = NULL;
cfg_t *cfg_general, *cfg_styles, *cfg_screen, *cfg_tags,
*cfg_layouts, *cfg_padding, *cfgsectmp,
*cfg_layouts, *cfg_padding, *cfgsectmp, *cfg_titlebar,
*cfg_styles_normal, *cfg_styles_focus, *cfg_styles_urgent;
VirtScreen *virtscreen = &globalconf.screens[screen];
int i, phys_screen = get_phys_screen(screen);
@ -303,6 +315,7 @@ config_parse_screen(cfg_t *cfg, int screen)
cfg_tags = cfg_getsec(cfg_screen, "tags");
cfg_styles = cfg_getsec(cfg_screen, "styles");
cfg_general = cfg_getsec(cfg_screen, "general");
cfg_titlebar = cfg_getsec(cfg_screen, "titlebar");
cfg_layouts = cfg_getsec(cfg_screen, "layouts");
cfg_padding = cfg_getsec(cfg_screen, "padding");
@ -319,8 +332,7 @@ config_parse_screen(cfg_t *cfg, int screen)
virtscreen->floating_placement =
name_func_lookup(cfg_getstr(cfg_general, "floating_placement"),
FloatingPlacementList);
virtscreen->titlebar_default_position =
position_get_from_str(cfg_getstr(cfg_general, "titlebar"));
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");
@ -526,8 +538,8 @@ config_parse(const char *confpatharg)
rule->isfloating = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "float"));
rule->screen = cfg_getint(cfgsectmp, "screen");
rule->ismaster = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "master"));
rule->titlebar = position_get_from_str(cfg_getstr(cfgsectmp, "titlebar"));
rule->opacity = cfg_getfloat(cfgsectmp, "opacity");
config_section_titlebar_init(cfg_getsec(cfgsectmp, "titlebar"), &rule->titlebar);
if(rule->screen >= globalconf.screens_info->nscreen)
rule->screen = 0;

View File

@ -40,6 +40,13 @@ typedef enum
enum
{ CurNormal, CurResize, CurMove, CurLast };
typedef struct
{
SimpleWindow *sw;
Position position;
Position icon;
} Titlebar;
/** Rule type */
typedef struct Rule Rule;
struct Rule
@ -49,7 +56,7 @@ struct Rule
int screen;
Fuzzy isfloating;
Fuzzy ismaster;
Position titlebar;
Titlebar titlebar;
double opacity;
regex_t *prop_r;
regex_t *tags_r;
@ -192,11 +199,7 @@ struct Client
/** True if the client is a new one */
Bool newcomer;
/** Titlebar */
struct
{
SimpleWindow *sw;
Position position;
} titlebar;
Titlebar titlebar;
};
typedef struct client_node_t client_node_t;
@ -257,8 +260,8 @@ typedef struct
typedef area_t (FloatingPlacement)(area_t, int, int);
typedef struct
{
/** Titlebar position */
Position titlebar_default_position;
/** Titlebar default parameters */
Titlebar titlebar_default;
/** Number of pixels to snap windows */
int snap;
/** Border size */