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 | make hotspot callback take an x11 button id (diff) | |
download | sway-14511da75da11aeef6427aed7fe170076649a957.tar.gz sway-14511da75da11aeef6427aed7fe170076649a957.tar.zst sway-14511da75da11aeef6427aed7fe170076649a957.zip |
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, | |||
155 | static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, | 155 | static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer, |
156 | uint32_t time, uint32_t axis, wl_fixed_t value) { | 156 | uint32_t time, uint32_t axis, wl_fixed_t value) { |
157 | struct swaybar *bar = data; | 157 | struct swaybar *bar = data; |
158 | struct swaybar_pointer *pointer = &bar->pointer; | ||
158 | struct swaybar_output *output = bar->pointer.current; | 159 | struct swaybar_output *output = bar->pointer.current; |
159 | if (!sway_assert(output, "axis with no active output")) { | 160 | if (!sway_assert(output, "axis with no active output")) { |
160 | return; | 161 | return; |
161 | } | 162 | } |
162 | 163 | ||
164 | struct swaybar_hotspot *hotspot; | ||
165 | wl_list_for_each(hotspot, &output->hotspots, link) { | ||
166 | double x = pointer->x * output->scale; | ||
167 | double y = pointer->y * output->scale; | ||
168 | if (x >= hotspot->x | ||
169 | && y >= hotspot->y | ||
170 | && x < hotspot->x + hotspot->width | ||
171 | && y < hotspot->y + hotspot->height) { | ||
172 | hotspot->callback(output, pointer->x, pointer->y, | ||
173 | wl_axis_to_x11_button(axis, value), hotspot->data); | ||
174 | return; | ||
175 | } | ||
176 | } | ||
177 | |||
163 | double amt = wl_fixed_to_double(value); | 178 | double amt = wl_fixed_to_double(value); |
164 | if (amt == 0.0) { | 179 | if (amt == 0.0) { |
165 | return; | 180 | return; |