aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/input.c')
-rw-r--r--swaybar/input.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/swaybar/input.c b/swaybar/input.c
index aa6290fa..c0352300 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -138,21 +138,23 @@ static bool check_bindings(struct swaybar *bar, uint32_t button,
138 return false; 138 return false;
139} 139}
140 140
141static void process_hotspots(struct swaybar_output *output, 141static bool process_hotspots(struct swaybar_output *output,
142 double x, double y, uint32_t button) { 142 double x, double y, uint32_t button) {
143 x *= output->scale; 143 double px = x * output->scale;
144 y *= output->scale; 144 double py = y * output->scale;
145 struct swaybar_hotspot *hotspot; 145 struct swaybar_hotspot *hotspot;
146 wl_list_for_each(hotspot, &output->hotspots, link) { 146 wl_list_for_each(hotspot, &output->hotspots, link) {
147 if (x >= hotspot->x && y >= hotspot->y 147 if (px >= hotspot->x && py >= hotspot->y
148 && x < hotspot->x + hotspot->width 148 && px < hotspot->x + hotspot->width
149 && y < hotspot->y + hotspot->height) { 149 && py < hotspot->y + hotspot->height) {
150 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, 150 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, x, y,
151 x / output->scale, y / output->scale, button, hotspot->data)) { 151 button, hotspot->data)) {
152 return; 152 return true;
153 } 153 }
154 } 154 }
155 } 155 }
156
157 return false;
156} 158}
157 159
158static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, 160static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
@@ -229,19 +231,8 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
229 return; 231 return;
230 } 232 }
231 233
232 struct swaybar_hotspot *hotspot; 234 if (process_hotspots(output, pointer->x, pointer->y, button)) {
233 wl_list_for_each(hotspot, &output->hotspots, link) { 235 return;
234 double x = pointer->x * output->scale;
235 double y = pointer->y * output->scale;
236 if (x >= hotspot->x
237 && y >= hotspot->y
238 && x < hotspot->x + hotspot->width
239 && y < hotspot->y + hotspot->height) {
240 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot,
241 pointer->x, pointer->y, button, hotspot->data)) {
242 return;
243 }
244 }
245 } 236 }
246 237
247 struct swaybar_config *config = seat->bar->config; 238 struct swaybar_config *config = seat->bar->config;