diff options
author | Peter Rice <peter@peterrice.xyz> | 2018-07-15 21:57:17 -0400 |
---|---|---|
committer | Peter Rice <peter@peterrice.xyz> | 2018-07-16 18:55:11 -0400 |
commit | 14511da75da11aeef6427aed7fe170076649a957 (patch) | |
tree | f5caf67e6e5c4ca47bc83e68c51301843add6f7a /swaybar | |
parent | 79a998849b8cedc9fccddfb31e4d1c99d1c17ff7 (diff) | |
download | sway-14511da75da11aeef6427aed7fe170076649a957.tar.xz |
send scroll events to swaybar blocks
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 1186d1e5..94bc48bc 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -155,11 +155,26 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { struct swaybar *bar = data; + struct swaybar_pointer *pointer = &bar->pointer; struct swaybar_output *output = bar->pointer.current; if (!sway_assert(output, "axis with no active output")) { return; } + struct swaybar_hotspot *hotspot; + wl_list_for_each(hotspot, &output->hotspots, link) { + double x = pointer->x * output->scale; + double y = pointer->y * output->scale; + if (x >= hotspot->x + && y >= hotspot->y + && x < hotspot->x + hotspot->width + && y < hotspot->y + hotspot->height) { + hotspot->callback(output, pointer->x, pointer->y, + wl_axis_to_x11_button(axis, value), hotspot->data); + return; + } + } + double amt = wl_fixed_to_double(value); if (amt == 0.0) { return; |