aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/i3bar.c
diff options
context:
space:
mode:
authorLibravatar Peter Rice <peter@peterrice.xyz>2018-07-15 20:16:37 -0400
committerLibravatar Peter Rice <peter@peterrice.xyz>2018-07-16 18:55:04 -0400
commit79a998849b8cedc9fccddfb31e4d1c99d1c17ff7 (patch)
tree1e2c2a54f588c4931cbf8b0cf2820029aee82bb4 /swaybar/i3bar.c
parentMerge pull request #2280 from ianyfan/leaks (diff)
downloadsway-79a998849b8cedc9fccddfb31e4d1c99d1c17ff7.tar.gz
sway-79a998849b8cedc9fccddfb31e4d1c99d1c17ff7.tar.zst
sway-79a998849b8cedc9fccddfb31e4d1c99d1c17ff7.zip
make hotspot callback take an x11 button id
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r--swaybar/i3bar.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 26f073c8..a615fb27 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -1,5 +1,6 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <json-c/json.h> 2#include <json-c/json.h>
3#include <linux/input-event-codes.h>
3#include <stdlib.h> 4#include <stdlib.h>
4#include <string.h> 5#include <string.h>
5#include <unistd.h> 6#include <unistd.h>
@@ -192,7 +193,7 @@ bool i3bar_handle_readable(struct status_line *status) {
192} 193}
193 194
194void i3bar_block_send_click(struct status_line *status, 195void i3bar_block_send_click(struct status_line *status,
195 struct i3bar_block *block, int x, int y, uint32_t button) { 196 struct i3bar_block *block, int x, int y, enum x11_button button) {
196 wlr_log(WLR_DEBUG, "block %s clicked", block->name ? block->name : "(nil)"); 197 wlr_log(WLR_DEBUG, "block %s clicked", block->name ? block->name : "(nil)");
197 if (!block->name || !status->i3bar_state.click_events) { 198 if (!block->name || !status->i3bar_state.click_events) {
198 return; 199 return;
@@ -215,3 +216,32 @@ void i3bar_block_send_click(struct status_line *status,
215 } 216 }
216 json_object_put(event_json); 217 json_object_put(event_json);
217} 218}
219
220enum x11_button wl_button_to_x11_button(uint32_t button) {
221 switch (button) {
222 case (BTN_LEFT):
223 return LEFT;
224 case (BTN_MIDDLE):
225 return MIDDLE;
226 case (BTN_RIGHT):
227 return RIGHT;
228 case (BTN_SIDE):
229 return BACK;
230 case (BTN_EXTRA):
231 return FORWARD;
232 default:
233 return NONE;
234 }
235}
236
237enum x11_button wl_axis_to_x11_button(uint32_t axis, wl_fixed_t value) {
238 switch (axis) {
239 case WL_POINTER_AXIS_VERTICAL_SCROLL:
240 return wl_fixed_to_double(value) < 0 ? SCROLL_UP : SCROLL_DOWN;
241 case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
242 return wl_fixed_to_double(value) < 0 ? SCROLL_LEFT : SCROLL_RIGHT;
243 default:
244 wlr_log(WLR_DEBUG, "Unexpected axis value on mouse scroll");
245 return NONE;
246 }
247}