diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-07-23 20:27:56 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-07-23 20:31:11 -0400 |
commit | f4b882475eee7a81c206c7825616cc4656b2f60b (patch) | |
tree | 38e6ebf81b235424f105dcbcbb194e5e9eac70c0 /swaybar/i3bar.c | |
parent | acd79e1505c06089e4fb9fb6c0c6e1d351ba9176 (diff) | |
parent | 224ade138208e9aa525423cbfbd643aa9d9b63c3 (diff) |
Merge branch 'master' into pid-workspaces
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r-- | swaybar/i3bar.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index 141612a6..ae37eeb9 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c @@ -1,5 +1,6 @@ #define _POSIX_C_SOURCE 200809L #include <json-c/json.h> +#include <linux/input-event-codes.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -31,7 +32,7 @@ static bool i3bar_parse_json(struct status_line *status, const char *text) { status_error(status, "[failed to parse i3bar json]"); return false; } - wlr_log(L_DEBUG, "Got i3bar json: '%s'", text); + wlr_log(WLR_DEBUG, "Got i3bar json: '%s'", text); for (size_t i = 0; i < json_object_array_length(results); ++i) { json_object *full_text, *short_text, *color, *min_width, *align, *urgent; json_object *name, *instance, *separator, *separator_block_width; @@ -191,11 +192,11 @@ bool i3bar_handle_readable(struct status_line *status) { return redraw; } -void i3bar_block_send_click(struct status_line *status, - struct i3bar_block *block, int x, int y, uint32_t button) { - wlr_log(L_DEBUG, "block %s clicked", block->name ? block->name : "(nil)"); +enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, + 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; + return HOTSPOT_PROCESS; } struct json_object *event_json = json_object_new_object(); @@ -214,4 +215,34 @@ void i3bar_block_send_click(struct status_line *status, status_error(status, "[failed to write click event]"); } json_object_put(event_json); + return HOTSPOT_IGNORE; +} + +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; + } } |