diff options
Diffstat (limited to 'swaybar/input.c')
-rw-r--r-- | swaybar/input.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/swaybar/input.c b/swaybar/input.c index f12eed79..8eccf542 100644 --- a/swaybar/input.c +++ b/swaybar/input.c | |||
@@ -141,14 +141,15 @@ static bool check_bindings(struct swaybar *bar, uint32_t button, | |||
141 | } | 141 | } |
142 | 142 | ||
143 | static bool process_hotspots(struct swaybar_output *output, | 143 | static bool process_hotspots(struct swaybar_output *output, |
144 | double x, double y, uint32_t button) { | 144 | double x, double y, uint32_t button, uint32_t state) { |
145 | bool released = state == WL_POINTER_BUTTON_STATE_RELEASED; | ||
145 | struct swaybar_hotspot *hotspot; | 146 | struct swaybar_hotspot *hotspot; |
146 | wl_list_for_each(hotspot, &output->hotspots, link) { | 147 | wl_list_for_each(hotspot, &output->hotspots, link) { |
147 | if (x >= hotspot->x && y >= hotspot->y | 148 | if (x >= hotspot->x && y >= hotspot->y |
148 | && x < hotspot->x + hotspot->width | 149 | && x < hotspot->x + hotspot->width |
149 | && y < hotspot->y + hotspot->height) { | 150 | && y < hotspot->y + hotspot->height) { |
150 | if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, x, y, | 151 | if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, x, y, |
151 | button, hotspot->data)) { | 152 | button, released, hotspot->data)) { |
152 | return true; | 153 | return true; |
153 | } | 154 | } |
154 | } | 155 | } |
@@ -166,10 +167,8 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, | |||
166 | return; | 167 | return; |
167 | } | 168 | } |
168 | 169 | ||
169 | if (state == WL_POINTER_BUTTON_STATE_PRESSED) { | 170 | if (process_hotspots(output, pointer->x, pointer->y, button, state)) { |
170 | if (process_hotspots(output, pointer->x, pointer->y, button)) { | 171 | return; |
171 | return; | ||
172 | } | ||
173 | } | 172 | } |
174 | 173 | ||
175 | check_bindings(seat->bar, button, state); | 174 | check_bindings(seat->bar, button, state); |
@@ -222,7 +221,8 @@ static void process_discrete_scroll(struct swaybar_seat *seat, | |||
222 | struct swaybar_output *output, struct swaybar_pointer *pointer, | 221 | struct swaybar_output *output, struct swaybar_pointer *pointer, |
223 | uint32_t axis, wl_fixed_t value) { | 222 | uint32_t axis, wl_fixed_t value) { |
224 | uint32_t button = wl_axis_to_button(axis, value); | 223 | uint32_t button = wl_axis_to_button(axis, value); |
225 | if (process_hotspots(output, pointer->x, pointer->y, button)) { | 224 | if (process_hotspots(output, pointer->x, pointer->y, button, WL_POINTER_BUTTON_STATE_PRESSED)) { |
225 | // (Currently hotspots don't do anything on release events, so no need to emit one) | ||
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
@@ -401,7 +401,8 @@ static void wl_touch_up(void *data, struct wl_touch *wl_touch, | |||
401 | } | 401 | } |
402 | if (time - slot->time < 500) { | 402 | if (time - slot->time < 500) { |
403 | // Tap, treat it like a pointer click | 403 | // Tap, treat it like a pointer click |
404 | process_hotspots(slot->output, slot->x, slot->y, BTN_LEFT); | 404 | process_hotspots(slot->output, slot->x, slot->y, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED); |
405 | // (Currently hotspots don't do anything on release events, so no need to emit one) | ||
405 | } | 406 | } |
406 | slot->output = NULL; | 407 | slot->output = NULL; |
407 | } | 408 | } |