particle/progress-bar: expand and replace on-click handler on click events only

No need to do it in motion events.
This commit is contained in:
Daniel Eklöf 2019-09-23 18:39:03 +02:00
parent 6e50872933
commit 012162837d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -147,6 +147,10 @@ on_mouse(struct exposable *exposable, struct bar *bar, enum mouse_event event,
return;
}
/* Remember the original handler, so that we can restore it */
char *original = exposable->on_click;
if (event == ON_MOUSE_CLICK) {
long where = clickable_width > 0
? 100 * (x - x_offset) / clickable_width
: 0;
@ -156,17 +160,19 @@ on_mouse(struct exposable *exposable, struct bar *bar, enum mouse_event event,
.count = 1,
};
char *original = exposable->on_click;
exposable->on_click = tags_expand_template(exposable->on_click, &tags);
tag_set_destroy(&tags);
}
/* Call default implementation, which will execute our handler */
exposable_default_on_mouse(exposable, bar, event, x, y);
if (event == ON_MOUSE_CLICK) {
/* Reset handler string */
free(exposable->on_click);
exposable->on_click = original;
}
}
static struct exposable *
instantiate(const struct particle *particle, const struct tag_set *tags)