aboutsummaryrefslogtreecommitdiff
path: root/swaybar/i3bar.c
diff options
context:
space:
mode:
authorRyan Dwyer <RyanDwyer@users.noreply.github.com>2018-07-18 09:32:03 +1000
committerGitHub <noreply@github.com>2018-07-18 09:32:03 +1000
commit8ce7e3b44eea0a270ecc35a9da2ae801aaf6bce1 (patch)
tree6badffb0c6ee33b4e23e914c4c9f9b39a625b5f3 /swaybar/i3bar.c
parent621d2666b1ac214c63628bbe0ac8f5d6485cb501 (diff)
parent48b911a4596f50b585a1073d32413236d9defb60 (diff)
downloadsway-8ce7e3b44eea0a270ecc35a9da2ae801aaf6bce1.tar.xz
Merge branch 'master' into destroy-output-destroy-empty-workspaces
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r--swaybar/i3bar.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 141612a6..78b183ad 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;
@@ -192,8 +193,8 @@ 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) {
- wlr_log(L_DEBUG, "block %s clicked", block->name ? block->name : "(nil)");
+ 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;
+ }
+}