summaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2019-01-13 20:41:05 -0500
committerLibravatar GitHub <noreply@github.com>2019-01-13 20:41:05 -0500
commit81bb6752748436788418c2fa3e7bef775c42c262 (patch)
treef90b770d160cf5ca773a3d63d52311f7ba731b16 /sway/ipc-json.c
parentMerge pull request #3343 from RedSoxFan/seat-cursor-buttons-improved (diff)
parentbar_cmd_bind: utilize mouse button helpers (diff)
downloadsway-81bb6752748436788418c2fa3e7bef775c42c262.tar.gz
sway-81bb6752748436788418c2fa3e7bef775c42c262.tar.zst
sway-81bb6752748436788418c2fa3e7bef775c42c262.zip
Merge pull request #3344 from RedSoxFan/bar-mouse-bindings-improved
Improve mouse button parsing: bar mouse bindings
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c29
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
652static 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
650json_object *ipc_json_describe_bar_config(struct bar_config *bar) { 677json_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));