diff options
| author | emersion <contact@emersion.fr> | 2018-07-18 00:16:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-18 00:16:15 +0100 |
| commit | 48b911a4596f50b585a1073d32413236d9defb60 (patch) | |
| tree | a225ff763a647e669cb8c7962b0bc333a8cf86a7 /swaybar/bar.c | |
| parent | bec982bba62db39f734d21ffbd2a3c8cefb3f6bd (diff) | |
| parent | e43c20134ab48ab36391443860cbdf4ac67d8348 (diff) | |
Merge pull request #2281 from pvsr/X11_click
Send clicks to swaybar blocks as X11 button ids
Diffstat (limited to 'swaybar/bar.c')
| -rw-r--r-- | swaybar/bar.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index f03c5aea..94bc48bc 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -147,7 +147,7 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer, && x < hotspot->x + hotspot->width && y < hotspot->y + hotspot->height) { hotspot->callback(output, pointer->x, pointer->y, - button, hotspot->data); + wl_button_to_x11_button(button), hotspot->data); } } } @@ -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; |
