diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-01-09 15:12:08 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-01-09 15:12:08 -0500 |
commit | 46992d60608c2f1251544d78333c67426962507e (patch) | |
tree | 844764ee2c6a96500eda012860e34acbb0ce793d /sway | |
parent | 93c93dd0f7aa27fc31702bd91f055f5bac45fe3c (diff) | |
parent | 15621ea8ffdfe9e0a85ac395297c45bb3b3eb0de (diff) |
Merge pull request #443 from mikkeloscar/binding-event-input_code
Add bindcode to binding events.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-server.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index bde20931..8d92b919 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -667,20 +667,39 @@ void ipc_event_binding_keyboard(struct sway_binding *sb) { json_object_object_add(sb_obj, "event_state_mask", modifiers); - // TODO: implement bindcode - json_object_object_add(sb_obj, "input_code", json_object_new_int(0)); - + json_object *input_codes = json_object_new_array(); + int input_code = 0; json_object *symbols = json_object_new_array(); - uint32_t keysym; - char buffer[64]; - for (i = 0; i < sb->keys->length; ++i) { - keysym = *(uint32_t *)sb->keys->items[i]; - if (xkb_keysym_get_name(keysym, buffer, 64) > 0) { - json_object_array_add(symbols, json_object_new_string(buffer)); + json_object *symbol = NULL; + + if (sb->bindcode) { // bindcode: populate input_codes + uint32_t keycode; + for (i = 0; i < sb->keys->length; ++i) { + keycode = *(uint32_t *)sb->keys->items[i]; + json_object_array_add(input_codes, json_object_new_int(keycode)); + if (i == 0) { + input_code = keycode; + } + } + } else { // bindsym: populate symbols + uint32_t keysym; + char buffer[64]; + for (i = 0; i < sb->keys->length; ++i) { + keysym = *(uint32_t *)sb->keys->items[i]; + if (xkb_keysym_get_name(keysym, buffer, 64) > 0) { + json_object *str = json_object_new_string(buffer); + json_object_array_add(symbols, str); + if (i == 0) { + symbol = str; + } + } } } + json_object_object_add(sb_obj, "input_codes", input_codes); + json_object_object_add(sb_obj, "input_code", json_object_new_int(input_code)); json_object_object_add(sb_obj, "symbols", symbols); + json_object_object_add(sb_obj, "symbol", symbol); json_object_object_add(sb_obj, "input_type", json_object_new_string("keyboard")); ipc_event_binding(sb_obj); |