diff options
author | nyorain <nyorain@gmail.com> | 2017-08-17 14:34:31 +0200 |
---|---|---|
committer | nyorain <nyorain@gmail.com> | 2017-08-17 14:34:31 +0200 |
commit | edbaa7d6ac0bdbe3230b75e7cf7664dbda7207e0 (patch) | |
tree | 30e7f11f634cd5eff5d38c1c2ff7c8e0326c566e | |
parent | 2db04c369e7e98e8205fac7d1e273dd775efb768 (diff) |
Update keyboard modifiers in example compositor
-rw-r--r-- | examples/compositor/main.c | 10 | ||||
-rw-r--r-- | examples/shared.c | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/examples/compositor/main.c b/examples/compositor/main.c index 54d31eb1..1fe81046 100644 --- a/examples/compositor/main.c +++ b/examples/compositor/main.c @@ -110,6 +110,16 @@ static void handle_keyboard_key(struct keyboard_state *keyboard, uint32_t keycod } if (seat_handle && seat_handle->keyboard) { + uint32_t depressed = xkb_state_serialize_mods(keyboard->xkb_state, + XKB_STATE_MODS_DEPRESSED); + uint32_t latched = xkb_state_serialize_mods(keyboard->xkb_state, + XKB_STATE_MODS_LATCHED); + uint32_t locked = xkb_state_serialize_mods(keyboard->xkb_state, + XKB_STATE_MODS_LOCKED); + uint32_t group = xkb_state_serialize_layout(keyboard->xkb_state, + XKB_STATE_LAYOUT_EFFECTIVE); + wl_keyboard_send_modifiers(seat_handle->keyboard, ++sample->serial, depressed, + latched, locked, group); wl_keyboard_send_key(seat_handle->keyboard, ++sample->serial, 0, keycode, key_state); } } diff --git a/examples/shared.c b/examples/shared.c index bd60bc42..58aef21a 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -32,6 +32,9 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { enum wlr_key_state key_state = event->state; const xkb_keysym_t *syms; int nsyms = xkb_state_key_get_syms(kbstate->xkb_state, keycode, &syms); + xkb_state_update_key(kbstate->xkb_state, keycode, + event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP); + keyboard_led_update(kbstate); for (int i = 0; i < nsyms; ++i) { xkb_keysym_t sym = syms[i]; char name[64]; @@ -57,9 +60,6 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { } } } - xkb_state_update_key(kbstate->xkb_state, keycode, - event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP); - keyboard_led_update(kbstate); } static void keyboard_add(struct wlr_input_device *device, struct compositor_state *state) { |