forked from external/yambar
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long where = clickable_width > 0
|
/* Remember the original handler, so that we can restore it */
|
||||||
? 100 * (x - x_offset) / clickable_width
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
struct tag_set tags = {
|
|
||||||
.tags = (struct tag *[]){tag_new_int(NULL, "where", where)},
|
|
||||||
.count = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
char *original = exposable->on_click;
|
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 */
|
/* Call default implementation, which will execute our handler */
|
||||||
exposable_default_on_mouse(exposable, bar, event, x, y);
|
exposable_default_on_mouse(exposable, bar, event, x, y);
|
||||||
|
|
||||||
/* Reset handler string */
|
if (event == ON_MOUSE_CLICK) {
|
||||||
free(exposable->on_click);
|
/* Reset handler string */
|
||||||
exposable->on_click = original;
|
free(exposable->on_click);
|
||||||
|
exposable->on_click = original;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct exposable *
|
static struct exposable *
|
||||||
|
|
Loading…
Add table
Reference in a new issue