From 91fed5419cd8c4284d6a9336f48434226afa8c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 3 Dec 2013 09:14:27 +0100 Subject: [PATCH] input: Reset keyboard state when releasing last seat keyboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't rely on the input driver to properly send button-up events for every pressed key. Signed-off-by: Jonas Ã…dahl --- src/input.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/input.c b/src/input.c index 04c3cdb8..e2910ea6 100644 --- a/src/input.c +++ b/src/input.c @@ -1987,6 +1987,29 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) return 0; } +static void +weston_keyboard_reset_state(struct weston_keyboard *keyboard) +{ + struct weston_seat *seat = keyboard->seat; + struct xkb_state *state; + +#ifdef ENABLE_XKBCOMMON + if (seat->compositor->use_xkbcommon) { + state = xkb_state_new(keyboard->xkb_info->keymap); + if (!state) { + weston_log("failed to reset XKB state\n"); + return; + } + xkb_state_unref(keyboard->xkb_state.state); + keyboard->xkb_state.state = state; + + keyboard->xkb_state.leds = 0; + } +#endif + + seat->modifier_state = 0; +} + WL_EXPORT void weston_seat_release_keyboard(struct weston_seat *seat) { @@ -1994,6 +2017,7 @@ weston_seat_release_keyboard(struct weston_seat *seat) if (seat->keyboard_device_count == 0) { weston_keyboard_set_focus(seat->keyboard, NULL); weston_keyboard_cancel_grab(seat->keyboard); + weston_keyboard_reset_state(seat->keyboard); seat_send_updated_caps(seat); } }