optimize if statements

This commit is contained in:
Julien Danjou 2008-01-04 13:04:15 +01:00
parent 86a970cde1
commit e3de02d2ce
1 changed files with 8 additions and 4 deletions

12
event.c
View File

@ -74,22 +74,25 @@ handle_event_buttonpress(XEvent *e)
{ {
if(statusbar->position == BarTop if(statusbar->position == BarTop
|| globalconf.screens[screen].statusbar->position == BarBot) || globalconf.screens[screen].statusbar->position == BarBot)
{
for(widget = statusbar->widgets; widget; widget = widget->next) for(widget = statusbar->widgets; widget; widget = widget->next)
if(ev->x >= widget->location && ev->x <= widget->location + widget->width) if(ev->x >= widget->location && ev->x <= widget->location + widget->width)
{ {
widget->button_press(widget, ev); widget->button_press(widget, ev);
return; return;
} }
}
if(statusbar->position == BarRight) else if(statusbar->position == BarRight)
{
for(widget = statusbar->widgets; widget; widget = widget->next) for(widget = statusbar->widgets; widget; widget = widget->next)
if(ev->y >= widget->location && ev->y <= widget->location + widget->width) if(ev->y >= widget->location && ev->y <= widget->location + widget->width)
{ {
widget->button_press(widget, ev); widget->button_press(widget, ev);
return; return;
} }
}
if(statusbar->position == BarLeft) else
{
for(widget = statusbar->widgets; widget; widget = widget->next) for(widget = statusbar->widgets; widget; widget = widget->next)
if(statusbar->width - ev->y >= widget->location if(statusbar->width - ev->y >= widget->location
&& statusbar->width - ev->y <= widget->location + widget->width) && statusbar->width - ev->y <= widget->location + widget->width)
@ -98,6 +101,7 @@ handle_event_buttonpress(XEvent *e)
return; return;
} }
} }
}
if((c = get_client_bywin(globalconf.clients, ev->window))) if((c = get_client_bywin(globalconf.clients, ev->window)))
{ {