factorize mouse button press event handling for status bar
This commit is contained in:
parent
0bee56e27d
commit
95938f8fef
66
event.c
66
event.c
|
@ -137,10 +137,30 @@ resizemouse(Client * c, awesome_config *awesomeconf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_mouse_button_press(awesome_config *awesomeconf,
|
||||||
|
unsigned int button, unsigned int state, unsigned int numlockmask,
|
||||||
|
Button *buttons, int nbuttons, char *arg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < nbuttons; i++)
|
||||||
|
if(button == buttons[i].button
|
||||||
|
&& (state == buttons[i].mod || state == (buttons[i].mod | numlockmask))
|
||||||
|
&& buttons[i].func)
|
||||||
|
{
|
||||||
|
if(arg)
|
||||||
|
buttons[i].func(awesomeconf, arg);
|
||||||
|
else
|
||||||
|
buttons[i].func(awesomeconf, buttons[i].arg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
void
|
void
|
||||||
handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
int i, j, screen, x = 0, y = 0;
|
int i, screen, x = 0, y = 0;
|
||||||
unsigned int udummy;
|
unsigned int udummy;
|
||||||
Client *c;
|
Client *c;
|
||||||
Window wdummy;
|
Window wdummy;
|
||||||
|
@ -156,47 +176,21 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
||||||
if(ev->x < x)
|
if(ev->x < x)
|
||||||
{
|
{
|
||||||
snprintf(arg, sizeof(arg), "%d", i + 1);
|
snprintf(arg, sizeof(arg), "%d", i + 1);
|
||||||
for(j = 0; j < awesomeconf[screen].buttons.ntag; j++)
|
handle_mouse_button_press(&awesomeconf[screen],
|
||||||
{
|
ev->button, ev->state, awesomeconf->numlockmask,
|
||||||
if(ev->button == awesomeconf[screen].buttons.tag[j].button
|
awesomeconf->buttons.tag, awesomeconf->buttons.ntag, arg);
|
||||||
&& (ev->state == awesomeconf[screen].buttons.tag[j].mod
|
|
||||||
|| ev->state == (awesomeconf[screen].buttons.tag[j].mod | awesomeconf[screen].numlockmask))
|
|
||||||
&& awesomeconf[screen].buttons.tag[j].func)
|
|
||||||
{
|
|
||||||
awesomeconf[screen].buttons.tag[j].func(&awesomeconf[screen], arg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += awesomeconf[screen].statusbar.txtlayoutwidth;
|
x += awesomeconf[screen].statusbar.txtlayoutwidth;
|
||||||
if(ev->x <x)
|
if(ev->x <x)
|
||||||
{
|
handle_mouse_button_press(&awesomeconf[screen],
|
||||||
for(j = 0; j < awesomeconf[screen].buttons.nlayout; j++)
|
ev->button, ev->state, awesomeconf->numlockmask,
|
||||||
if(ev->button == awesomeconf[screen].buttons.layout[j].button
|
awesomeconf->buttons.layout, awesomeconf->buttons.nlayout, NULL);
|
||||||
&& (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
|
else
|
||||||
{
|
handle_mouse_button_press(&awesomeconf[screen],
|
||||||
for(j = 0; j < awesomeconf[screen].buttons.ntitle; j++)
|
ev->button, ev->state, awesomeconf->numlockmask,
|
||||||
if(ev->button == awesomeconf[screen].buttons.title[j].button
|
awesomeconf->buttons.title, awesomeconf->buttons.ntitle, NULL);
|
||||||
&& (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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue