diff options
author | 2018-07-18 00:16:15 +0100 | |
---|---|---|
committer | 2018-07-18 00:16:15 +0100 | |
commit | 48b911a4596f50b585a1073d32413236d9defb60 (patch) | |
tree | a225ff763a647e669cb8c7962b0bc333a8cf86a7 /swaybar/bar.c | |
parent | Merge pull request #2289 from frsfnrrg/memory-fixes (diff) | |
parent | remove unnecessary parens (diff) | |
download | sway-48b911a4596f50b585a1073d32413236d9defb60.tar.gz sway-48b911a4596f50b585a1073d32413236d9defb60.tar.zst sway-48b911a4596f50b585a1073d32413236d9defb60.zip |
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, | |||
147 | && x < hotspot->x + hotspot->width | 147 | && x < hotspot->x + hotspot->width |
148 | && y < hotspot->y + hotspot->height) { | 148 | && y < hotspot->y + hotspot->height) { |
149 | hotspot->callback(output, pointer->x, pointer->y, | 149 | hotspot->callback(output, pointer->x, pointer->y, |
150 | button, hotspot->data); | 150 | wl_button_to_x11_button(button), hotspot->data); |
151 | } | 151 | } |
152 | } | 152 | } |
153 | } | 153 | } |
@@ -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; |