mouse buttons are now configurable for click on layout symbols

This commit is contained in:
Julien Danjou 2007-11-11 16:01:49 +01:00
parent 99370f0ccd
commit 0bee56e27d
4 changed files with 39 additions and 4 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

17
event.c
View File

@ -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 <x)
{
for(j = 0; j < awesomeconf[screen].buttons.nlayout; j++)
if(ev->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++)