diff --git a/src/config.c b/src/config.c index dcc8b00..147f139 100644 --- a/src/config.c +++ b/src/config.c @@ -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); diff --git a/src/config_struct.h b/src/config_struct.h index d89e342..1031e32 100644 --- a/src/config_struct.h +++ b/src/config_struct.h @@ -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), diff --git a/src/event.c b/src/event.c index 23f9709..224b260 100644 --- a/src/event.c +++ b/src/event.c @@ -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) diff --git a/src/structs.h b/src/structs.h index aea2017..fd84a1d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -285,6 +285,11 @@ typedef struct uint layout_bg; } colors; struct + { + MouseBinding *mouse; + int nmouse; + } bars; + struct { char *background_command; MouseBinding *mouse; diff --git a/src/wmfs.c b/src/wmfs.c index e4f7e1c..f5c5f2c 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -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);