mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-22 12:25:38 +02:00
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:
parent
6e50872933
commit
012162837d
1 changed files with 20 additions and 14 deletions
|
@ -147,25 +147,31 @@ on_mouse(struct exposable *exposable, struct bar *bar, enum mouse_event event,
|
|||
return;
|
||||
}
|
||||
|
||||
long where = clickable_width > 0
|
||||
? 100 * (x - x_offset) / clickable_width
|
||||
: 0;
|
||||
|
||||
struct tag_set tags = {
|
||||
.tags = (struct tag *[]){tag_new_int(NULL, "where", where)},
|
||||
.count = 1,
|
||||
};
|
||||
|
||||
/* Remember the original handler, so that we can restore it */
|
||||
char *original = exposable->on_click;
|
||||
exposable->on_click = tags_expand_template(exposable->on_click, &tags);
|
||||
tag_set_destroy(&tags);
|
||||
|
||||
if (event == ON_MOUSE_CLICK) {
|
||||
long where = clickable_width > 0
|
||||
? 100 * (x - x_offset) / clickable_width
|
||||
: 0;
|
||||
|
||||
struct tag_set tags = {
|
||||
.tags = (struct tag *[]){tag_new_int(NULL, "where", where)},
|
||||
.count = 1,
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
/* Reset handler string */
|
||||
free(exposable->on_click);
|
||||
exposable->on_click = original;
|
||||
if (event == ON_MOUSE_CLICK) {
|
||||
/* Reset handler string */
|
||||
free(exposable->on_click);
|
||||
exposable->on_click = original;
|
||||
}
|
||||
}
|
||||
|
||||
static struct exposable *
|
||||
|
|
Loading…
Add table
Reference in a new issue