conf: Add tag selection for root mouse binding configuration (mouse { tag = x button = .... )

This commit is contained in:
Martin Duquesnoy 2008-11-24 01:00:33 +01:00
parent 5a510cbd66
commit 71bec3d1bb
3 changed files with 8 additions and 3 deletions

View File

@ -63,6 +63,7 @@ static cfg_opt_t bar_opts[] =
static cfg_opt_t mouse_button_opts[] =
{
CFG_INT("tag", -1, CFGF_NONE),
CFG_STR("button", "Button1", CFGF_NONE),
CFG_STR("func", "", CFGF_NONE),
CFG_STR("cmd", "", CFGF_NONE),
@ -315,6 +316,7 @@ mouse_section(MouseBinding mb[], cfg_t *cfg, int ns)
for(i = 0; i < ns; ++i)
{
tmp = cfg_getnsec(cfg, "mouse", i);
mb[i].tag = cfg_getint(tmp, "tag");
mb[i].button = char_to_button(cfg_getstr(tmp, "button"));
mb[i].func = name_to_func(cfg_getstr(tmp, "func"), func_list);
mb[i].cmd = strdup(var_to_str(cfg_getstr(tmp, "cmd")));

View File

@ -63,9 +63,11 @@ buttonpress(XButtonEvent *ev)
/* Root */
if(ev->window == root)
for(i = 0; i < conf.root.nmouse; ++i)
if(ev->button == conf.root.mouse[i].button)
if(conf.root.mouse[i].func)
conf.root.mouse[i].func(conf.root.mouse[i].cmd);
if(conf.root.mouse[i].tag == seltag
|| conf.root.mouse[i].tag < 0)
if(ev->button == conf.root.mouse[i].button)
if(conf.root.mouse[i].func)
conf.root.mouse[i].func(conf.root.mouse[i].cmd);
/* Tag */
for(i = 1; i < conf.ntag + 1; ++i)

View File

@ -121,6 +121,7 @@ typedef struct
/* Mouse Binding Struct */
typedef struct
{
int tag;
uint button;
void (*func)(uicb_t);
uicb_t cmd;