summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/ipc-server.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index aea45851..8d92b919 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -668,13 +668,18 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) {
668 json_object_object_add(sb_obj, "event_state_mask", modifiers); 668 json_object_object_add(sb_obj, "event_state_mask", modifiers);
669 669
670 json_object *input_codes = json_object_new_array(); 670 json_object *input_codes = json_object_new_array();
671 int input_code = 0;
671 json_object *symbols = json_object_new_array(); 672 json_object *symbols = json_object_new_array();
673 json_object *symbol = NULL;
672 674
673 if (sb->bindcode) { // bindcode: populate input_codes 675 if (sb->bindcode) { // bindcode: populate input_codes
674 uint32_t keycode; 676 uint32_t keycode;
675 for (i = 0; i < sb->keys->length; ++i) { 677 for (i = 0; i < sb->keys->length; ++i) {
676 keycode = *(uint32_t *)sb->keys->items[i]; 678 keycode = *(uint32_t *)sb->keys->items[i];
677 json_object_array_add(input_codes, json_object_new_int(keycode)); 679 json_object_array_add(input_codes, json_object_new_int(keycode));
680 if (i == 0) {
681 input_code = keycode;
682 }
678 } 683 }
679 } else { // bindsym: populate symbols 684 } else { // bindsym: populate symbols
680 uint32_t keysym; 685 uint32_t keysym;
@@ -682,13 +687,19 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) {
682 for (i = 0; i < sb->keys->length; ++i) { 687 for (i = 0; i < sb->keys->length; ++i) {
683 keysym = *(uint32_t *)sb->keys->items[i]; 688 keysym = *(uint32_t *)sb->keys->items[i];
684 if (xkb_keysym_get_name(keysym, buffer, 64) > 0) { 689 if (xkb_keysym_get_name(keysym, buffer, 64) > 0) {
685 json_object_array_add(symbols, json_object_new_string(buffer)); 690 json_object *str = json_object_new_string(buffer);
691 json_object_array_add(symbols, str);
692 if (i == 0) {
693 symbol = str;
694 }
686 } 695 }
687 } 696 }
688 } 697 }
689 698
690 json_object_object_add(sb_obj, "input_codes", input_codes); 699 json_object_object_add(sb_obj, "input_codes", input_codes);
700 json_object_object_add(sb_obj, "input_code", json_object_new_int(input_code));
691 json_object_object_add(sb_obj, "symbols", symbols); 701 json_object_object_add(sb_obj, "symbols", symbols);
702 json_object_object_add(sb_obj, "symbol", symbol);
692 json_object_object_add(sb_obj, "input_type", json_object_new_string("keyboard")); 703 json_object_object_add(sb_obj, "input_type", json_object_new_string("keyboard"));
693 704
694 ipc_event_binding(sb_obj); 705 ipc_event_binding(sb_obj);