From 48eb77207bff01ae766a9fb33b4e4c35cfad62c9 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Mon, 24 Jul 2023 09:51:10 -0500 Subject: [PATCH] wayland: restore xkb_keysym_to_utf8 handling In 1f8013ff3fddd788a517656e09f5ce5d7efd928d, I mistakenly thought this was only used for modifier presses way back in the commit it was introduced in, but it actually also handles non-english keys/letters. Instead of returning early, we should try xkb_keysym_to_utf8 first and then return if that doesn't do anything so the modifier can then be handled in the appropriate event. Fixes #12009. --- video/out/wayland_common.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 799dad543fe..2e6722c8c23 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -436,15 +436,20 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard, xkb_keysym_t sym = xkb_state_key_get_one_sym(wl->xkb_state, wl->keyboard_code); int mpkey = lookupkey(sym); - // Assume a modifier was pressed and handle it in the mod event instead. - if (!mpkey && MP_KEY_STATE_DOWN) - return; - state = state == WL_KEYBOARD_KEY_STATE_PRESSED ? MP_KEY_STATE_DOWN : MP_KEY_STATE_UP; - if (mpkey) + if (mpkey) { mp_input_put_key(wl->vo->input_ctx, mpkey | state | wl->mpmod); + } else { + char s[128]; + if (xkb_keysym_to_utf8(sym, s, sizeof(s)) > 0) { + mp_input_put_key_utf8(wl->vo->input_ctx, state | wl->mpmod, bstr0(s)); + } else { + // Assume a modifier was pressed and handle it in the mod event instead. + return; + } + } if (state == MP_KEY_STATE_DOWN) wl->mpkey = mpkey; if (wl->mpkey == mpkey && state == MP_KEY_STATE_UP)