From 79a998849b8cedc9fccddfb31e4d1c99d1c17ff7 Mon Sep 17 00:00:00 2001 From: Peter Rice Date: Sun, 15 Jul 2018 20:16:37 -0400 Subject: make hotspot callback take an x11 button id --- swaybar/i3bar.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'swaybar/i3bar.c') 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 @@ #define _POSIX_C_SOURCE 200809L #include +#include #include #include #include @@ -192,7 +193,7 @@ bool i3bar_handle_readable(struct status_line *status) { } void i3bar_block_send_click(struct status_line *status, - struct i3bar_block *block, int x, int y, uint32_t button) { + struct i3bar_block *block, int x, int y, enum x11_button button) { wlr_log(WLR_DEBUG, "block %s clicked", block->name ? block->name : "(nil)"); if (!block->name || !status->i3bar_state.click_events) { return; @@ -215,3 +216,32 @@ void i3bar_block_send_click(struct status_line *status, } json_object_put(event_json); } + +enum x11_button wl_button_to_x11_button(uint32_t button) { + switch (button) { + case (BTN_LEFT): + return LEFT; + case (BTN_MIDDLE): + return MIDDLE; + case (BTN_RIGHT): + return RIGHT; + case (BTN_SIDE): + return BACK; + case (BTN_EXTRA): + return FORWARD; + default: + return NONE; + } +} + +enum x11_button wl_axis_to_x11_button(uint32_t axis, wl_fixed_t value) { + switch (axis) { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + return wl_fixed_to_double(value) < 0 ? SCROLL_UP : SCROLL_DOWN; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + return wl_fixed_to_double(value) < 0 ? SCROLL_LEFT : SCROLL_RIGHT; + default: + wlr_log(WLR_DEBUG, "Unexpected axis value on mouse scroll"); + return NONE; + } +} -- cgit v1.2.3-54-g00ecf From e43c20134ab48ab36391443860cbdf4ac67d8348 Mon Sep 17 00:00:00 2001 From: Peter Rice Date: Tue, 17 Jul 2018 19:00:38 -0400 Subject: remove unnecessary parens --- swaybar/i3bar.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'swaybar/i3bar.c') diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index a615fb27..78b183ad 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c @@ -219,15 +219,15 @@ void i3bar_block_send_click(struct status_line *status, enum x11_button wl_button_to_x11_button(uint32_t button) { switch (button) { - case (BTN_LEFT): + case BTN_LEFT: return LEFT; - case (BTN_MIDDLE): + case BTN_MIDDLE: return MIDDLE; - case (BTN_RIGHT): + case BTN_RIGHT: return RIGHT; - case (BTN_SIDE): + case BTN_SIDE: return BACK; - case (BTN_EXTRA): + case BTN_EXTRA: return FORWARD; default: return NONE; -- cgit v1.2.3-54-g00ecf