diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 15f89f65..6e5ba4fd 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/backend/libinput.h> | 16 | #include <wlr/backend/libinput.h> |
15 | #include <wlr/types/wlr_box.h> | 17 | #include <wlr/types/wlr_box.h> |
@@ -647,6 +649,31 @@ json_object *ipc_json_describe_seat(struct sway_seat *seat) { | |||
647 | return object; | 649 | return object; |
648 | } | 650 | } |
649 | 651 | ||
652 | static uint32_t event_to_x11_button(uint32_t event) { | ||
653 | switch (event) { | ||
654 | case BTN_LEFT: | ||
655 | return 1; | ||
656 | case BTN_MIDDLE: | ||
657 | return 2; | ||
658 | case BTN_RIGHT: | ||
659 | return 3; | ||
660 | case SWAY_SCROLL_UP: | ||
661 | return 4; | ||
662 | case SWAY_SCROLL_DOWN: | ||
663 | return 5; | ||
664 | case SWAY_SCROLL_LEFT: | ||
665 | return 6; | ||
666 | case SWAY_SCROLL_RIGHT: | ||
667 | return 7; | ||
668 | case BTN_SIDE: | ||
669 | return 8; | ||
670 | case BTN_EXTRA: | ||
671 | return 9; | ||
672 | default: | ||
673 | return 0; | ||
674 | } | ||
675 | } | ||
676 | |||
650 | json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | 677 | json_object *ipc_json_describe_bar_config(struct bar_config *bar) { |
651 | if (!sway_assert(bar, "Bar must not be NULL")) { | 678 | if (!sway_assert(bar, "Bar must not be NULL")) { |
652 | return NULL; | 679 | return NULL; |
@@ -792,6 +819,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
792 | struct bar_binding *binding = bar->bindings->items[i]; | 819 | struct bar_binding *binding = bar->bindings->items[i]; |
793 | json_object *bind = json_object_new_object(); | 820 | json_object *bind = json_object_new_object(); |
794 | json_object_object_add(bind, "input_code", | 821 | json_object_object_add(bind, "input_code", |
822 | json_object_new_int(event_to_x11_button(binding->button))); | ||
823 | json_object_object_add(bind, "event_code", | ||
795 | json_object_new_int(binding->button)); | 824 | json_object_new_int(binding->button)); |
796 | json_object_object_add(bind, "command", | 825 | json_object_object_add(bind, "command", |
797 | json_object_new_string(binding->command)); | 826 | json_object_new_string(binding->command)); |