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.
This commit is contained in:
nanahi authored and Dudemanguy committed 2024-05-24 17:57:55 +00:00
1 parent 0fcfbab9af
commit 2fa66b850d
1 file changed
+11 -3
+11 -3
View File
@@ -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 {