Conf: Add multi mouse section possible in bar section.

This commit is contained in:
Martin Duquesnoy 2009-03-26 20:31:23 +01:00
parent 9c6cb3573f
commit 4d5883bbf0
5 changed files with 37 additions and 11 deletions

View File

@ -138,6 +138,13 @@ conf_bar_section(cfg_t *cfg_b)
conf.colors.bar = getcolor(alias_to_str(cfg_getstr(cfg_b, "bg")));
conf.colors.text = _strdup(alias_to_str(cfg_getstr(cfg_b, "fg")));
if((conf.bars.nmouse = cfg_size(cfg_b, "mouse")))
{
conf.bars.mouse = emalloc(conf.bars.nmouse, sizeof(MouseBinding));
mouse_section(conf.bars.mouse, cfg_b, conf.bars.nmouse);
}
return;
}
@ -145,8 +152,8 @@ void
conf_root_section(cfg_t *cfg_r)
{
conf.root.background_command = _strdup(alias_to_str(cfg_getstr(cfg_r, "background_command")));
conf.root.nmouse = cfg_size(cfg_r, "mouse");
if(conf.root.nmouse)
if((conf.root.nmouse = cfg_size(cfg_r, "mouse")))
{
conf.root.mouse = emalloc(conf.root.nmouse, sizeof(MouseBinding));
mouse_section(conf.root.mouse, cfg_r, conf.root.nmouse);

View File

@ -45,14 +45,6 @@ cfg_opt_t misc_opts[] =
CFG_END()
};
cfg_opt_t bar_opts[] =
{
CFG_STR("bg", "#090909", CFGF_NONE),
CFG_STR("fg", "#6289A1", CFGF_NONE),
CFG_BOOL("border", cfg_false, CFGF_NONE),
CFG_END()
};
cfg_opt_t mouse_button_opts[] =
{
CFG_INT("tag", -1, CFGF_NONE),
@ -63,6 +55,15 @@ cfg_opt_t mouse_button_opts[] =
CFG_END()
};
cfg_opt_t bar_opts[] =
{
CFG_STR("bg", "#090909", CFGF_NONE),
CFG_STR("fg", "#6289A1", CFGF_NONE),
CFG_BOOL("border", cfg_false, CFGF_NONE),
CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI),
CFG_END()
};
cfg_opt_t root_opts[] =
{
CFG_STR("background_command", "", CFGF_NONE),

View File

@ -39,7 +39,7 @@ void
buttonpress(XButtonEvent *ev)
{
Client *c;
int i, n, x, y;
int i, j, n, x, y;
screen_get_sel();
@ -77,6 +77,18 @@ buttonpress(XButtonEvent *ev)
if(conf.root.mouse[i].func)
conf.root.mouse[i].func(conf.root.mouse[i].cmd);
/* Infobars */
for(i = 0; i < screen_count(); ++i)
if(ev->window == infobar[i].bar->win)
for(j = 0; j < conf.bars.nmouse; ++j)
if(conf.bars.mouse[j].screen == i)
if(conf.bars.mouse[j].tag == seltag[i]
|| conf.bars.mouse[j].tag < 0)
if(ev->button == conf.bars.mouse[j].button)
if(conf.bars.mouse[j].func)
conf.bars.mouse[j].func(conf.bars.mouse[j].cmd);
/* Tags */
for(i = 1; i < conf.ntag[selscreen] + 1; ++i)
if(ev->window == infobar[selscreen].tags[i]->win)

View File

@ -285,6 +285,11 @@ typedef struct
uint layout_bg;
} colors;
struct
{
MouseBinding *mouse;
int nmouse;
} bars;
struct
{
char *background_command;
MouseBinding *mouse;

View File

@ -129,6 +129,7 @@ quit(void)
IFREE(conf.titlebar.button[i].linecoord);
}
IFREE(conf.bars.mouse);
IFREE(conf.titlebar.button);
IFREE(conf.client.mouse);
IFREE(conf.root.mouse);