From 2fa66b850df1e0ecd653e9eea1e69fccc73afcee Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Wed, 22 May 2024 10:16:02 -0400 Subject: [PATCH] wayland_common: ignore unknown key states Once https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/368 is merged and we upgrade wl_seat version to 10, compositors will also generate "repeated" events, which mpv treats as key up right now. Change the check so that unknown key states are ignored. --- video/out/wayland_common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index b824c8a266..aa91a687be 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1886,13 +1886,21 @@ static void handle_key_input(struct vo_wayland_seat *s, uint32_t key, { struct vo_wayland_state *wl = s->wl; + switch (state) { + case WL_KEYBOARD_KEY_STATE_RELEASED: + state = MP_KEY_STATE_UP; + break; + case WL_KEYBOARD_KEY_STATE_PRESSED: + state = MP_KEY_STATE_DOWN; + break; + default: + return; + } + s->keyboard_code = key + 8; xkb_keysym_t sym = xkb_state_key_get_one_sym(s->xkb_state, s->keyboard_code); int mpkey = lookupkey(sym); - state = state == WL_KEYBOARD_KEY_STATE_PRESSED ? MP_KEY_STATE_DOWN - : MP_KEY_STATE_UP; - if (mpkey) { mp_input_put_key(wl->vo->input_ctx, mpkey | state | s->mpmod); } else {