From 71bec3d1bb43ec8b411cc03af3432b3dfbc7ca7f Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Mon, 24 Nov 2008 01:00:33 +0100 Subject: [PATCH] conf: Add tag selection for root mouse binding configuration (mouse { tag = x button = .... ) --- src/config.c | 2 ++ src/event.c | 8 +++++--- src/structs.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 07343fc..92faeb5 100644 --- a/src/config.c +++ b/src/config.c @@ -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"))); diff --git a/src/event.c b/src/event.c index ba487c0..aa6ed11 100644 --- a/src/event.c +++ b/src/event.c @@ -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) diff --git a/src/structs.h b/src/structs.h index ea00daa..a270186 100644 --- a/src/structs.h +++ b/src/structs.h @@ -121,6 +121,7 @@ typedef struct /* Mouse Binding Struct */ typedef struct { + int tag; uint button; void (*func)(uicb_t); uicb_t cmd;