taglist now supports clicks if statusbar is right/left

This commit is contained in:
Julien Danjou 2008-01-04 13:22:24 +01:00
parent 65fe4e8933
commit 8485c13b1b
1 changed files with 37 additions and 7 deletions

View File

@ -119,11 +119,12 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
for(b = widget->buttons; b; b = b->next) for(b = widget->buttons; b; b = b->next)
if(ev->button == b->button && CLEANMASK(ev->state) == b->mod && b->func) if(ev->button == b->button && CLEANMASK(ev->state) == b->mod && b->func)
for(tag = vscreen.tags; tag; tag = tag->next, i++) {
{ if(widget->statusbar->position == BarTop
width = textwidth(vscreen.font, tag->name) + vscreen.font->height; || widget->statusbar->position == BarBot)
if(widget->statusbar->position == BarTop for(tag = vscreen.tags; tag; tag = tag->next, i++)
|| widget->statusbar->position == BarBot) {
width = textwidth(vscreen.font, tag->name) + vscreen.font->height;
if(ev->x >= widget->location + prev_width if(ev->x >= widget->location + prev_width
&& ev->x <= widget->location + prev_width + width) && ev->x <= widget->location + prev_width + width)
{ {
@ -131,8 +132,37 @@ taglist_button_press(Widget *widget, XButtonPressedEvent *ev)
b->func(widget->statusbar->screen, buf); b->func(widget->statusbar->screen, buf);
return; return;
} }
prev_width += width; prev_width += width;
} }
else if(widget->statusbar->position == BarRight)
for(tag = vscreen.tags; tag; tag = tag->next, i++)
{
width = textwidth(vscreen.font, tag->name) + vscreen.font->height;
if(ev->y >= widget->location + prev_width
&& ev->y <= widget->location + prev_width + width)
{
snprintf(buf, sizeof(buf), "%d", i);
b->func(widget->statusbar->screen, buf);
return;
}
prev_width += width;
}
else
for(tag = vscreen.tags; tag; tag = tag->next, i++)
{
width = textwidth(vscreen.font, tag->name) + vscreen.font->height;
if(widget->statusbar->width - ev->y >= widget->location + prev_width
&& widget->statusbar->width - ev->y <= widget->location + prev_width + width)
{
snprintf(buf, sizeof(buf), "%d", i);
b->func(widget->statusbar->screen, buf);
return;
}
prev_width += width;
}
}
} }
Widget * Widget *