aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 12:43:10 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 12:43:10 -0500
commit3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72 (patch)
tree05e5dddd092b3d3ba16166a3784a49923e9f3de2
parentMerge pull request #3400 from ianyfan/config-brace (diff)
downloadsway-3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72.tar.gz
sway-3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72.tar.zst
sway-3d6440ec26f2b39c54fd03aa3a3c822a8a2bbc72.zip
bar_cmd_bind: utilize mouse button helpers
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing mouse buttons. This also introduces `cmd_bar_bindcode`, which will use `get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the two commands are encapsulated in a single file with shared code. This also modifies swaybar to operate off of event codes rather than x11 button numbers, which allows for any mouse button to be used. This introduces two new IPC properties: - For `get_bar_config`, `event_code` has been added to the `bindings` section and will include to event code for the button. If the event code can be mapped to a x11 button, `input_code` will still be the x11 button number. Otherwise, `input_code` will be `0`. - Likewise for `click_events`, `event` has been added and will include the event code for the button clicked. If the event code can be mapped to a x11 button, `button` will still be the x11 button number. Otherwise, `button` will be `0`.
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/swaybar/i3bar.h2
-rw-r--r--include/swaybar/input.h9
-rw-r--r--sway/commands/bar.c1
-rw-r--r--sway/commands/bar/bind.c106
-rw-r--r--sway/commands/bar/bindsym.c68
-rw-r--r--sway/ipc-json.c29
-rw-r--r--sway/meson.build2
-rw-r--r--sway/sway-bar.5.scd16
-rw-r--r--swaybar/i3bar.c31
-rw-r--r--swaybar/input.c36
-rw-r--r--swaybar/ipc.c2
-rw-r--r--swaybar/render.c19
13 files changed, 208 insertions, 114 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 7d0ff838..ffc18789 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -183,6 +183,7 @@ sway_cmd cmd_workspace;
183sway_cmd cmd_ws_auto_back_and_forth; 183sway_cmd cmd_ws_auto_back_and_forth;
184sway_cmd cmd_workspace_layout; 184sway_cmd cmd_workspace_layout;
185 185
186sway_cmd bar_cmd_bindcode;
186sway_cmd bar_cmd_binding_mode_indicator; 187sway_cmd bar_cmd_binding_mode_indicator;
187sway_cmd bar_cmd_bindsym; 188sway_cmd bar_cmd_bindsym;
188sway_cmd bar_cmd_colors; 189sway_cmd bar_cmd_colors;
diff --git a/include/swaybar/i3bar.h b/include/swaybar/i3bar.h
index ab4744a5..aa4415ff 100644
--- a/include/swaybar/i3bar.h
+++ b/include/swaybar/i3bar.h
@@ -28,6 +28,6 @@ void i3bar_block_unref(struct i3bar_block *block);
28bool i3bar_handle_readable(struct status_line *status); 28bool i3bar_handle_readable(struct status_line *status);
29enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, 29enum hotspot_event_handling i3bar_block_send_click(struct status_line *status,
30 struct i3bar_block *block, int x, int y, int rx, int ry, int w, int h, 30 struct i3bar_block *block, int x, int y, int rx, int ry, int w, int h,
31 enum x11_button button); 31 uint32_t button);
32 32
33#endif 33#endif
diff --git a/include/swaybar/input.h b/include/swaybar/input.h
index f480d009..4b46b0de 100644
--- a/include/swaybar/input.h
+++ b/include/swaybar/input.h
@@ -4,6 +4,11 @@
4#include <wayland-client.h> 4#include <wayland-client.h>
5#include "list.h" 5#include "list.h"
6 6
7#define SWAY_SCROLL_UP KEY_MAX + 1
8#define SWAY_SCROLL_DOWN KEY_MAX + 2
9#define SWAY_SCROLL_LEFT KEY_MAX + 3
10#define SWAY_SCROLL_RIGHT KEY_MAX + 4
11
7struct swaybar; 12struct swaybar;
8struct swaybar_output; 13struct swaybar_output;
9 14
@@ -39,8 +44,8 @@ struct swaybar_hotspot {
39 struct wl_list link; // swaybar_output::hotspots 44 struct wl_list link; // swaybar_output::hotspots
40 int x, y, width, height; 45 int x, y, width, height;
41 enum hotspot_event_handling (*callback)(struct swaybar_output *output, 46 enum hotspot_event_handling (*callback)(struct swaybar_output *output,
42 struct swaybar_hotspot *hotspot, int x, int y, 47 struct swaybar_hotspot *hotspot, int x, int y, uint32_t button,
43 enum x11_button button, void *data); 48 void *data);
44 void (*destroy)(void *data); 49 void (*destroy)(void *data);
45 void *data; 50 void *data;
46}; 51};
diff --git a/sway/commands/bar.c b/sway/commands/bar.c
index 507ee10a..ee5a8ebf 100644
--- a/sway/commands/bar.c
+++ b/sway/commands/bar.c
@@ -8,6 +8,7 @@
8 8
9// Must be in alphabetical order for bsearch 9// Must be in alphabetical order for bsearch
10static struct cmd_handler bar_handlers[] = { 10static struct cmd_handler bar_handlers[] = {
11 { "bindcode", bar_cmd_bindcode },
11 { "binding_mode_indicator", bar_cmd_binding_mode_indicator }, 12 { "binding_mode_indicator", bar_cmd_binding_mode_indicator },
12 { "bindsym", bar_cmd_bindsym }, 13 { "bindsym", bar_cmd_bindsym },
13 { "colors", bar_cmd_colors }, 14 { "colors", bar_cmd_colors },
diff --git a/sway/commands/bar/bind.c b/sway/commands/bar/bind.c
new file mode 100644
index 00000000..a4c65ec4
--- /dev/null
+++ b/sway/commands/bar/bind.c
@@ -0,0 +1,106 @@
1#include <libevdev/libevdev.h>
2#include <stdlib.h>
3#include <string.h>
4#include <strings.h>
5#include "sway/commands.h"
6#include "sway/config.h"
7#include "sway/input/cursor.h"
8#include "list.h"
9#include "log.h"
10#include "stringop.h"
11
12static struct cmd_results *bar_cmd_bind(int argc, char **argv, bool code) {
13 const char *command = code ? "bar bindcode" : "bar bindsym";
14 struct cmd_results *error = NULL;
15 if ((error = checkarg(argc, command, EXPECTED_AT_LEAST, 2))) {
16 return error;
17 }
18 if (!config->current_bar) {
19 return cmd_results_new(CMD_FAILURE, command, "No bar defined.");
20 }
21
22 struct bar_binding *binding = calloc(1, sizeof(struct bar_binding));
23 if (!binding) {
24 return cmd_results_new(CMD_FAILURE, command,
25 "Unable to allocate bar binding");
26 }
27
28 binding->release = false;
29 if (strcmp("--release", argv[0]) == 0) {
30 binding->release = true;
31 argv++;
32 argc--;
33 }
34
35 char *message = NULL;
36 if (code) {
37 binding->button = get_mouse_bindcode(argv[0], &message);
38 } else {
39 binding->button = get_mouse_bindsym(argv[0], &message);
40 }
41 if (message) {
42 free_bar_binding(binding);
43 error = cmd_results_new(CMD_INVALID, command, message);
44 free(message);
45 return error;
46 } else if (!binding->button) {
47 free_bar_binding(binding);
48 return cmd_results_new(CMD_INVALID, command,
49 "Unknown button %s", argv[0]);
50 }
51
52 const char *name = libevdev_event_code_get_name(EV_KEY, binding->button);
53 if (!name) {
54 switch (binding->button) {
55 case SWAY_SCROLL_UP:
56 name = "SWAY_SCROLL_UP";
57 break;
58 case SWAY_SCROLL_DOWN:
59 name = "SWAY_SCROLL_DOWN";
60 break;
61 case SWAY_SCROLL_LEFT:
62 name = "SWAY_SCROLL_LEFT";
63 break;
64 case SWAY_SCROLL_RIGHT:
65 name = "SWAY_SCROLL_RIGHT";
66 break;
67 default:
68 // Unreachable
69 break;
70 }
71 }
72
73 binding->command = join_args(argv + 1, argc - 1);
74
75 list_t *bindings = config->current_bar->bindings;
76 bool overwritten = false;
77 for (int i = 0; i < bindings->length; i++) {
78 struct bar_binding *other = bindings->items[i];
79 if (other->button == binding->button &&
80 other->release == binding->release) {
81 overwritten = true;
82 bindings->items[i] = binding;
83 free_bar_binding(other);
84 wlr_log(WLR_DEBUG, "[bar %s] Updated binding for %u (%s)%s",
85 config->current_bar->id, binding->button, name,
86 binding->release ? " - release" : "");
87 break;
88 }
89 }
90 if (!overwritten) {
91 list_add(bindings, binding);
92 wlr_log(WLR_DEBUG, "[bar %s] Added binding for %u (%s)%s",
93 config->current_bar->id, binding->button, name,
94 binding->release ? " - release" : "");
95 }
96
97 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
98}
99
100struct cmd_results *bar_cmd_bindcode(int argc, char **argv) {
101 return bar_cmd_bind(argc, argv, true);
102}
103
104struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
105 return bar_cmd_bind(argc, argv, false);
106}
diff --git a/sway/commands/bar/bindsym.c b/sway/commands/bar/bindsym.c
deleted file mode 100644
index e6d6220e..00000000
--- a/sway/commands/bar/bindsym.c
+++ /dev/null
@@ -1,68 +0,0 @@
1#include <stdlib.h>
2#include <string.h>
3#include <strings.h>
4#include "sway/commands.h"
5#include "sway/config.h"
6#include "list.h"
7#include "log.h"
8#include "stringop.h"
9
10struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
11 struct cmd_results *error = NULL;
12 if ((error = checkarg(argc, "bar bindsym", EXPECTED_AT_LEAST, 2))) {
13 return error;
14 }
15 if (!config->current_bar) {
16 return cmd_results_new(CMD_FAILURE, "bar bindsym", "No bar defined.");
17 }
18
19 struct bar_binding *binding = calloc(1, sizeof(struct bar_binding));
20 if (!binding) {
21 return cmd_results_new(CMD_FAILURE, "bar bindsym",
22 "Unable to allocate bar binding");
23 }
24
25 binding->release = false;
26 if (strcmp("--release", argv[0]) == 0) {
27 binding->release = true;
28 argv++;
29 argc--;
30 }
31
32 binding->button = 0;
33 if (strncasecmp(argv[0], "button", strlen("button")) == 0 &&
34 strlen(argv[0]) == strlen("button0")) {
35 binding->button = argv[0][strlen("button")] - '0';
36 }
37 if (binding->button < 1 || binding->button > 9) {
38 free_bar_binding(binding);
39 return cmd_results_new(CMD_FAILURE, "bar bindsym",
40 "Only button<1-9> is supported");
41 }
42
43 binding->command = join_args(argv + 1, argc - 1);
44
45 list_t *bindings = config->current_bar->bindings;
46 bool overwritten = false;
47 for (int i = 0; i < bindings->length; i++) {
48 struct bar_binding *other = bindings->items[i];
49 if (other->button == binding->button &&
50 other->release == binding->release) {
51 overwritten = true;
52 bindings->items[i] = binding;
53 free_bar_binding(other);
54 wlr_log(WLR_DEBUG, "[bar %s] Updated binding for button%u%s",
55 config->current_bar->id, binding->button,
56 binding->release ? " (release)" : "");
57 break;
58 }
59 }
60 if (!overwritten) {
61 list_add(bindings, binding);
62 wlr_log(WLR_DEBUG, "[bar %s] Added binding for button%u%s",
63 config->current_bar->id, binding->button,
64 binding->release ? " (release)" : "");
65 }
66
67 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
68}
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 53e0e335..61602343 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -1,4 +1,5 @@
1#include <json-c/json.h> 1#include <json-c/json.h>
2#include <libevdev/libevdev.h>
2#include <stdio.h> 3#include <stdio.h>
3#include <ctype.h> 4#include <ctype.h>
4#include "config.h" 5#include "config.h"
@@ -10,6 +11,7 @@
10#include "sway/tree/workspace.h" 11#include "sway/tree/workspace.h"
11#include "sway/output.h" 12#include "sway/output.h"
12#include "sway/input/input-manager.h" 13#include "sway/input/input-manager.h"
14#include "sway/input/cursor.h"
13#include "sway/input/seat.h" 15#include "sway/input/seat.h"
14#include <wlr/types/wlr_box.h> 16#include <wlr/types/wlr_box.h>
15#include <wlr/types/wlr_output.h> 17#include <wlr/types/wlr_output.h>
@@ -626,6 +628,31 @@ json_object *ipc_json_describe_seat(struct sway_seat *seat) {
626 return object; 628 return object;
627} 629}
628 630
631static uint32_t event_to_x11_button(uint32_t event) {
632 switch (event) {
633 case BTN_LEFT:
634 return 1;
635 case BTN_MIDDLE:
636 return 2;
637 case BTN_RIGHT:
638 return 3;
639 case SWAY_SCROLL_UP:
640 return 4;
641 case SWAY_SCROLL_DOWN:
642 return 5;
643 case SWAY_SCROLL_LEFT:
644 return 6;
645 case SWAY_SCROLL_RIGHT:
646 return 7;
647 case BTN_SIDE:
648 return 8;
649 case BTN_EXTRA:
650 return 9;
651 default:
652 return 0;
653 }
654}
655
629json_object *ipc_json_describe_bar_config(struct bar_config *bar) { 656json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
630 if (!sway_assert(bar, "Bar must not be NULL")) { 657 if (!sway_assert(bar, "Bar must not be NULL")) {
631 return NULL; 658 return NULL;
@@ -767,6 +794,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
767 struct bar_binding *binding = bar->bindings->items[i]; 794 struct bar_binding *binding = bar->bindings->items[i];
768 json_object *bind = json_object_new_object(); 795 json_object *bind = json_object_new_object();
769 json_object_object_add(bind, "input_code", 796 json_object_object_add(bind, "input_code",
797 json_object_new_int(event_to_x11_button(binding->button)));
798 json_object_object_add(bind, "event_code",
770 json_object_new_int(binding->button)); 799 json_object_new_int(binding->button));
771 json_object_object_add(bind, "command", 800 json_object_object_add(bind, "command",
772 json_object_new_string(binding->command)); 801 json_object_new_string(binding->command));
diff --git a/sway/meson.build b/sway/meson.build
index 98676ce0..9518c62b 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -100,8 +100,8 @@ sway_sources = files(
100 'commands/workspace_layout.c', 100 'commands/workspace_layout.c',
101 'commands/ws_auto_back_and_forth.c', 101 'commands/ws_auto_back_and_forth.c',
102 102
103 'commands/bar/bind.c',
103 'commands/bar/binding_mode_indicator.c', 104 'commands/bar/binding_mode_indicator.c',
104 'commands/bar/bindsym.c',
105 'commands/bar/colors.c', 105 'commands/bar/colors.c',
106 'commands/bar/font.c', 106 'commands/bar/font.c',
107 'commands/bar/gaps.c', 107 'commands/bar/gaps.c',
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd
index 2357591d..ac1949b7 100644
--- a/sway/sway-bar.5.scd
+++ b/sway/sway-bar.5.scd
@@ -71,10 +71,18 @@ Sway allows configuring swaybar in the sway configuration file.
71*height* <height> 71*height* <height>
72 Sets the height of the bar. Default height will match the font size. 72 Sets the height of the bar. Default height will match the font size.
73 73
74*bindsym* [--release] button<n> <command> 74*bindcode* [--release] <event-code> <command>
75 Executes _command_ when mouse button _n_ has been pressed (or if _released_ 75 Executes _command_ when the mouse button has been pressed (or if _released_
76 is given, when mouse button _n_ has been released). To disable the default 76 is given, when the button has been released). The buttons can be given as
77 behavior for a button, use the command _nop_. 77 an event code, which can be obtaining from `libinput debug-events`. To
78 disable the default behavior for a button, use the command _nop_.
79
80*bindsym* [--release] button[1-9]|<event-name> <command>
81 Executes _command_ when the mouse button has been pressed (or if _released_
82 is given, when the button has been released). The buttons can be given as a
83 x11 button number or an event name, which can be obtained from `libinput
84 debug-events`. To disable the default behavior for a button, use the
85 command _nop_.
78 86
79*mode* dock|hide|invisible 87*mode* dock|hide|invisible
80 Specifies the visibility of the bar. In _dock_ mode, it is permanently 88 Specifies the visibility of the bar. In _dock_ mode, it is permanently
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 54607a3a..116c8f6e 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -259,9 +259,34 @@ bool i3bar_handle_readable(struct status_line *status) {
259 } 259 }
260} 260}
261 261
262static uint32_t event_to_x11_button(uint32_t event) {
263 switch (event) {
264 case BTN_LEFT:
265 return 1;
266 case BTN_MIDDLE:
267 return 2;
268 case BTN_RIGHT:
269 return 3;
270 case SWAY_SCROLL_UP:
271 return 4;
272 case SWAY_SCROLL_DOWN:
273 return 5;
274 case SWAY_SCROLL_LEFT:
275 return 6;
276 case SWAY_SCROLL_RIGHT:
277 return 7;
278 case BTN_SIDE:
279 return 8;
280 case BTN_EXTRA:
281 return 9;
282 default:
283 return 0;
284 }
285}
286
262enum hotspot_event_handling i3bar_block_send_click(struct status_line *status, 287enum hotspot_event_handling i3bar_block_send_click(struct status_line *status,
263 struct i3bar_block *block, int x, int y, int rx, int ry, int w, int h, 288 struct i3bar_block *block, int x, int y, int rx, int ry, int w, int h,
264 enum x11_button button) { 289 uint32_t button) {
265 wlr_log(WLR_DEBUG, "block %s clicked", block->name); 290 wlr_log(WLR_DEBUG, "block %s clicked", block->name);
266 if (!block->name || !status->click_events) { 291 if (!block->name || !status->click_events) {
267 return HOTSPOT_PROCESS; 292 return HOTSPOT_PROCESS;
@@ -275,7 +300,9 @@ enum hotspot_event_handling i3bar_block_send_click(struct status_line *status,
275 json_object_new_string(block->instance)); 300 json_object_new_string(block->instance));
276 } 301 }
277 302
278 json_object_object_add(event_json, "button", json_object_new_int(button)); 303 json_object_object_add(event_json, "button",
304 json_object_new_int(event_to_x11_button(button)));
305 json_object_object_add(event_json, "event", json_object_new_int(button));
279 json_object_object_add(event_json, "x", json_object_new_int(x)); 306 json_object_object_add(event_json, "x", json_object_new_int(x));
280 json_object_object_add(event_json, "y", json_object_new_int(y)); 307 json_object_object_add(event_json, "y", json_object_new_int(y));
281 json_object_object_add(event_json, "relative_x", json_object_new_int(rx)); 308 json_object_object_add(event_json, "relative_x", json_object_new_int(rx));
diff --git a/swaybar/input.c b/swaybar/input.c
index 620da977..bdd55e58 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -22,32 +22,16 @@ void free_hotspots(struct wl_list *list) {
22 } 22 }
23} 23}
24 24
25static enum x11_button wl_button_to_x11_button(uint32_t button) { 25static uint32_t wl_axis_to_button(uint32_t axis, wl_fixed_t value) {
26 switch (button) { 26 bool negative = wl_fixed_to_double(value) < 0;
27 case BTN_LEFT:
28 return LEFT;
29 case BTN_MIDDLE:
30 return MIDDLE;
31 case BTN_RIGHT:
32 return RIGHT;
33 case BTN_SIDE:
34 return BACK;
35 case BTN_EXTRA:
36 return FORWARD;
37 default:
38 return NONE;
39 }
40}
41
42static enum x11_button wl_axis_to_x11_button(uint32_t axis, wl_fixed_t value) {
43 switch (axis) { 27 switch (axis) {
44 case WL_POINTER_AXIS_VERTICAL_SCROLL: 28 case WL_POINTER_AXIS_VERTICAL_SCROLL:
45 return wl_fixed_to_double(value) < 0 ? SCROLL_UP : SCROLL_DOWN; 29 return negative ? SWAY_SCROLL_UP : SWAY_SCROLL_DOWN;
46 case WL_POINTER_AXIS_HORIZONTAL_SCROLL: 30 case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
47 return wl_fixed_to_double(value) < 0 ? SCROLL_LEFT : SCROLL_RIGHT; 31 return negative ? SWAY_SCROLL_LEFT : SWAY_SCROLL_RIGHT;
48 default: 32 default:
49 wlr_log(WLR_DEBUG, "Unexpected axis value on mouse scroll"); 33 wlr_log(WLR_DEBUG, "Unexpected axis value on mouse scroll");
50 return NONE; 34 return 0;
51 } 35 }
52} 36}
53 37
@@ -102,12 +86,12 @@ static void wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
102 bar->pointer.y = wl_fixed_to_int(surface_y); 86 bar->pointer.y = wl_fixed_to_int(surface_y);
103} 87}
104 88
105static bool check_bindings(struct swaybar *bar, uint32_t x11_button, 89static bool check_bindings(struct swaybar *bar, uint32_t button,
106 uint32_t state) { 90 uint32_t state) {
107 bool released = state == WL_POINTER_BUTTON_STATE_RELEASED; 91 bool released = state == WL_POINTER_BUTTON_STATE_RELEASED;
108 for (int i = 0; i < bar->config->bindings->length; i++) { 92 for (int i = 0; i < bar->config->bindings->length; i++) {
109 struct swaybar_binding *binding = bar->config->bindings->items[i]; 93 struct swaybar_binding *binding = bar->config->bindings->items[i];
110 if (binding->button == x11_button && binding->release == released) { 94 if (binding->button == button && binding->release == released) {
111 ipc_execute_binding(bar, binding); 95 ipc_execute_binding(bar, binding);
112 return true; 96 return true;
113 } 97 }
@@ -124,7 +108,7 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
124 return; 108 return;
125 } 109 }
126 110
127 if (check_bindings(bar, wl_button_to_x11_button(button), state)) { 111 if (check_bindings(bar, button, state)) {
128 return; 112 return;
129 } 113 }
130 114
@@ -140,7 +124,7 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
140 && x < hotspot->x + hotspot->width 124 && x < hotspot->x + hotspot->width
141 && y < hotspot->y + hotspot->height) { 125 && y < hotspot->y + hotspot->height) {
142 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot, 126 if (HOTSPOT_IGNORE == hotspot->callback(output, hotspot,
143 pointer->x, pointer->y, wl_button_to_x11_button(button), hotspot->data)) { 127 pointer->x, pointer->y, button, hotspot->data)) {
144 return; 128 return;
145 } 129 }
146 } 130 }
@@ -158,7 +142,7 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
158 142
159 // If there is a button press binding, execute it, skip default behavior, 143 // If there is a button press binding, execute it, skip default behavior,
160 // and check button release bindings 144 // and check button release bindings
161 enum x11_button button = wl_axis_to_x11_button(axis, value); 145 uint32_t button = wl_axis_to_button(axis, value);
162 if (check_bindings(bar, button, WL_POINTER_BUTTON_STATE_PRESSED)) { 146 if (check_bindings(bar, button, WL_POINTER_BUTTON_STATE_PRESSED)) {
163 check_bindings(bar, button, WL_POINTER_BUTTON_STATE_RELEASED); 147 check_bindings(bar, button, WL_POINTER_BUTTON_STATE_RELEASED);
164 return; 148 return;
diff --git a/swaybar/ipc.c b/swaybar/ipc.c
index 8e7a542e..ba53d95d 100644
--- a/swaybar/ipc.c
+++ b/swaybar/ipc.c
@@ -237,7 +237,7 @@ static bool ipc_parse_config(
237 struct swaybar_binding *binding = 237 struct swaybar_binding *binding =
238 calloc(1, sizeof(struct swaybar_binding)); 238 calloc(1, sizeof(struct swaybar_binding));
239 binding->button = json_object_get_int( 239 binding->button = json_object_get_int(
240 json_object_object_get(bindobj, "input_code")); 240 json_object_object_get(bindobj, "event_code"));
241 binding->command = strdup(json_object_get_string( 241 binding->command = strdup(json_object_get_string(
242 json_object_object_get(bindobj, "command"))); 242 json_object_object_get(bindobj, "command")));
243 binding->release = json_object_get_boolean( 243 binding->release = json_object_get_boolean(
diff --git a/swaybar/render.c b/swaybar/render.c
index 7cbcea07..670e8e74 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -1,5 +1,6 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <assert.h> 2#include <assert.h>
3#include <linux/input-event-codes.h>
3#include <limits.h> 4#include <limits.h>
4#include <stdlib.h> 5#include <stdlib.h>
5#include <stdint.h> 6#include <stdint.h>
@@ -126,13 +127,13 @@ static void render_sharp_line(cairo_t *cairo, uint32_t color,
126 } 127 }
127} 128}
128 129
129static enum hotspot_event_handling block_hotspot_callback(struct swaybar_output *output, 130static enum hotspot_event_handling block_hotspot_callback(
130 struct swaybar_hotspot *hotspot, 131 struct swaybar_output *output, struct swaybar_hotspot *hotspot,
131 int x, int y, enum x11_button button, void *data) { 132 int x, int y, uint32_t button, void *data) {
132 struct i3bar_block *block = data; 133 struct i3bar_block *block = data;
133 struct status_line *status = output->bar->status; 134 struct status_line *status = output->bar->status;
134 return i3bar_block_send_click(status, block, x, y, x - hotspot->x, y - hotspot->y, 135 return i3bar_block_send_click(status, block, x, y, x - hotspot->x,
135 hotspot->width, hotspot->height, button); 136 y - hotspot->y, hotspot->width, hotspot->height, button);
136} 137}
137 138
138static void i3bar_block_unref_callback(void *data) { 139static void i3bar_block_unref_callback(void *data) {
@@ -360,10 +361,10 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
360 return output->height; 361 return output->height;
361} 362}
362 363
363static enum hotspot_event_handling workspace_hotspot_callback(struct swaybar_output *output, 364static enum hotspot_event_handling workspace_hotspot_callback(
364 struct swaybar_hotspot *hotspot, 365 struct swaybar_output *output, struct swaybar_hotspot *hotspot,
365 int x, int y, enum x11_button button, void *data) { 366 int x, int y, uint32_t button, void *data) {
366 if (button != LEFT) { 367 if (button != BTN_LEFT) {
367 return HOTSPOT_PROCESS; 368 return HOTSPOT_PROCESS;
368 } 369 }
369 ipc_send_workspace_command(output->bar, (const char *)data); 370 ipc_send_workspace_command(output->bar, (const char *)data);