mouse buttons are now configurable for click on title bar

This commit is contained in:
Julien Danjou 2007-11-11 15:55:13 +01:00
parent 83f7087f13
commit 99370f0ccd
4 changed files with 39 additions and 6 deletions

View File

@ -68,6 +68,8 @@ cleanup_screen(awesome_config *awesomeconf)
p_delete(&awesomeconf->tags[i].name); p_delete(&awesomeconf->tags[i].name);
for(i = 0; i < awesomeconf->nkeys; i++) for(i = 0; i < awesomeconf->nkeys; i++)
p_delete(&awesomeconf->keys[i].arg); 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->nlayouts; i++) for(i = 0; i < awesomeconf->nlayouts; i++)
p_delete(&awesomeconf->layouts[i].symbol); p_delete(&awesomeconf->layouts[i].symbol);
for(i = 0; i < awesomeconf->nrules; i++) for(i = 0; i < awesomeconf->nrules; i++)
@ -80,6 +82,7 @@ cleanup_screen(awesome_config *awesomeconf)
p_delete(&awesomeconf->rules); p_delete(&awesomeconf->rules);
p_delete(&awesomeconf->keys); p_delete(&awesomeconf->keys);
p_delete(&awesomeconf->buttons.tag); p_delete(&awesomeconf->buttons.tag);
p_delete(&awesomeconf->buttons.title);
p_delete(&awesomeconf->configpath); p_delete(&awesomeconf->configpath);
} }

View File

@ -268,10 +268,18 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
CFG_STR((char *) "button", (char *) "None", CFGF_NONE), CFG_STR((char *) "button", (char *) "None", CFGF_NONE),
CFG_STR((char *) "command", (char *) "", CFGF_NONE), CFG_STR((char *) "command", (char *) "", CFGF_NONE),
}; };
static cfg_opt_t mouse_title_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_opts[] = static cfg_opt_t mouse_opts[] =
{ {
CFG_STR((char *) "modkey", (char *) "Mod4", CFGF_NONE), CFG_STR((char *) "modkey", (char *) "Mod4", CFGF_NONE),
CFG_SEC((char *) "tag", mouse_tag_opts, CFGF_MULTI), CFG_SEC((char *) "tag", mouse_tag_opts, CFGF_MULTI),
CFG_SEC((char *) "title", mouse_title_opts, CFGF_MULTI),
CFG_END() CFG_END()
}; };
static cfg_opt_t opts[] = static cfg_opt_t opts[] =
@ -367,7 +375,6 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
awesomeconf->statusbar.position = awesomeconf->statusbar.dposition; awesomeconf->statusbar.position = awesomeconf->statusbar.dposition;
/* Layouts */ /* Layouts */
awesomeconf->nlayouts = cfg_size(cfg_layouts, "layout"); awesomeconf->nlayouts = cfg_size(cfg_layouts, "layout");
awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts); awesomeconf->layouts = p_new(Layout, awesomeconf->nlayouts);
for(i = 0; i < awesomeconf->nlayouts; i++) for(i = 0; i < awesomeconf->nlayouts; i++)
@ -387,7 +394,6 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
eprint("awesome: fatal: no default layout available\n"); eprint("awesome: fatal: no default layout available\n");
/* Rules */ /* Rules */
awesomeconf->nrules = cfg_size(cfg_rules, "rule"); awesomeconf->nrules = cfg_size(cfg_rules, "rule");
awesomeconf->rules = p_new(Rule, awesomeconf->nrules); awesomeconf->rules = p_new(Rule, awesomeconf->nrules);
for(i = 0; i < awesomeconf->nrules; i++) for(i = 0; i < awesomeconf->nrules; i++)
@ -448,6 +454,19 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
awesomeconf->buttons.tag[i].arg = NULL; /* for now */ awesomeconf->buttons.tag[i].arg = NULL; /* for now */
} }
/* Mouse: title click bindings */
awesomeconf->buttons.ntitle = cfg_size(cfg_mouse, "title");
awesomeconf->buttons.title = p_new(Button, awesomeconf->buttons.ntitle);
for(i = 0; i < awesomeconf->buttons.ntitle; i++)
{
cfgsectmp = cfg_getnsec(cfg_mouse, "title", i);
for(j = 0; j < cfg_size(cfgsectmp, "modkey"); j++)
awesomeconf->buttons.title[i].mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", j));
awesomeconf->buttons.title[i].button = mouse_button_lookup(cfg_getstr(cfgsectmp, "button"));
awesomeconf->buttons.title[i].func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), UicbList);
awesomeconf->buttons.title[i].arg = a_strdup(cfg_getstr(cfgsectmp, "arg"));
}
/* Keys */ /* Keys */
awesomeconf->numlockmask = get_numlockmask(awesomeconf->display); awesomeconf->numlockmask = get_numlockmask(awesomeconf->display);
awesomeconf->nkeys = cfg_size(cfg_keys, "key"); awesomeconf->nkeys = cfg_size(cfg_keys, "key");

View File

@ -177,6 +177,8 @@ struct awesome_config
{ {
Button *tag; Button *tag;
int ntag; int ntag;
Button *title;
int ntitle;
} buttons; } buttons;
/** Number of keys binding in *keys */ /** Number of keys binding in *keys */
int nkeys; int nkeys;

17
event.c
View File

@ -175,10 +175,19 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
uicb_setlayout(&awesomeconf[screen], "+1"); uicb_setlayout(&awesomeconf[screen], "+1");
else if(ev->x < x && (ev->button == Button3 || ev->button == Button5)) else if(ev->x < x && (ev->button == Button3 || ev->button == Button5))
uicb_setlayout(&awesomeconf[screen], "-1"); uicb_setlayout(&awesomeconf[screen], "-1");
else if(ev->button == Button4) else
uicb_focusnext(&awesomeconf[screen], NULL); {
else if(ev->button == Button5) for(j = 0; j < awesomeconf[screen].buttons.ntitle; j++)
uicb_focusprev(&awesomeconf[screen], NULL); if(ev->button == awesomeconf[screen].buttons.title[j].button
&& (ev->state == awesomeconf[screen].buttons.title[j].mod
|| ev->state == (awesomeconf[screen].buttons.title[j].mod | awesomeconf[screen].numlockmask))
&& awesomeconf[screen].buttons.title[j].func)
{
awesomeconf[screen].buttons.title[j].func(&awesomeconf[screen],
awesomeconf[screen].buttons.title[j].arg);
return;
}
}
return; return;
} }