diff --git a/awesome.c b/awesome.c index 29edba004..1b60e77d8 100644 --- a/awesome.c +++ b/awesome.c @@ -70,6 +70,8 @@ cleanup_screen(awesome_config *awesomeconf) p_delete(&awesomeconf->keys[i].arg); for(i = 0; i< awesomeconf->buttons.ntitle; i++) p_delete(&awesomeconf->buttons.title[i].arg); + for(i = 0; i< awesomeconf->buttons.nlayout; i++) + p_delete(&awesomeconf->buttons.layout[i].arg); for(i = 0; i < awesomeconf->nlayouts; i++) p_delete(&awesomeconf->layouts[i].symbol); for(i = 0; i < awesomeconf->nrules; i++) @@ -83,6 +85,7 @@ cleanup_screen(awesome_config *awesomeconf) p_delete(&awesomeconf->keys); p_delete(&awesomeconf->buttons.tag); p_delete(&awesomeconf->buttons.title); + p_delete(&awesomeconf->buttons.layout); p_delete(&awesomeconf->configpath); } diff --git a/config.c b/config.c index 0d01fa458..5662c8551 100644 --- a/config.c +++ b/config.c @@ -268,6 +268,13 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) CFG_STR((char *) "button", (char *) "None", CFGF_NONE), CFG_STR((char *) "command", (char *) "", CFGF_NONE), }; + static cfg_opt_t mouse_layout_opts[] = + { + CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE), + CFG_STR((char *) "button", (char *) "None", CFGF_NONE), + CFG_STR((char *) "command", (char *) "", CFGF_NONE), + CFG_STR((char *) "arg", NULL, CFGF_NONE), + }; static cfg_opt_t mouse_title_opts[] = { CFG_STR_LIST((char *) "modkey", (char *) "{}", CFGF_NONE), @@ -279,6 +286,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) { CFG_STR((char *) "modkey", (char *) "Mod4", CFGF_NONE), CFG_SEC((char *) "tag", mouse_tag_opts, CFGF_MULTI), + CFG_SEC((char *) "layout", mouse_layout_opts, CFGF_MULTI), CFG_SEC((char *) "title", mouse_title_opts, CFGF_MULTI), CFG_END() }; @@ -454,6 +462,19 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) awesomeconf->buttons.tag[i].arg = NULL; /* for now */ } + /* Mouse: layout click bindings */ + awesomeconf->buttons.nlayout = cfg_size(cfg_mouse, "layout"); + awesomeconf->buttons.layout = p_new(Button, awesomeconf->buttons.nlayout); + for(i = 0; i < awesomeconf->buttons.nlayout; i++) + { + cfgsectmp = cfg_getnsec(cfg_mouse, "layout", i); + for(j = 0; j < cfg_size(cfgsectmp, "modkey"); j++) + awesomeconf->buttons.layout[i].mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", j)); + awesomeconf->buttons.layout[i].button = mouse_button_lookup(cfg_getstr(cfgsectmp, "button")); + awesomeconf->buttons.layout[i].func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), UicbList); + awesomeconf->buttons.layout[i].arg = a_strdup(cfg_getstr(cfgsectmp, "arg")); + } + /* Mouse: title click bindings */ awesomeconf->buttons.ntitle = cfg_size(cfg_mouse, "title"); awesomeconf->buttons.title = p_new(Button, awesomeconf->buttons.ntitle); diff --git a/config.h b/config.h index 8fa569fa4..b8df1d724 100644 --- a/config.h +++ b/config.h @@ -179,6 +179,8 @@ struct awesome_config int ntag; Button *title; int ntitle; + Button *layout; + int nlayout; } buttons; /** Number of keys binding in *keys */ int nkeys; diff --git a/event.c b/event.c index 89149d0d0..48b40b45c 100644 --- a/event.c +++ b/event.c @@ -171,10 +171,19 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf) } } x += awesomeconf[screen].statusbar.txtlayoutwidth; - if(ev->x < x && (ev->button == Button1 || ev->button == Button4)) - uicb_setlayout(&awesomeconf[screen], "+1"); - else if(ev->x < x && (ev->button == Button3 || ev->button == Button5)) - uicb_setlayout(&awesomeconf[screen], "-1"); + if(ev->x button == awesomeconf[screen].buttons.layout[j].button + && (ev->state == awesomeconf[screen].buttons.layout[j].mod + || ev->state == (awesomeconf[screen].buttons.layout[j].mod | awesomeconf[screen].numlockmask)) + && awesomeconf[screen].buttons.layout[j].func) + { + awesomeconf[screen].buttons.layout[j].func(&awesomeconf[screen], + awesomeconf[screen].buttons.layout[j].arg); + return; + } + } else { for(j = 0; j < awesomeconf[screen].buttons.ntitle; j++)