From 2f8dcac28b64cecd537ab1fad366b2c2052c2ead Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 1 Jul 2013 21:33:41 +0200 Subject: input: fix behavior if there are actually key up events Wayland is the only backend that actually sends per-key key up events (the X11 one just sends MP_INPUT_RELEASE_ALL for simplicity). Handling was broken with Wayland, and each key event was interpreted twice, once on key down and once on key up. This commit should fix it. --- core/input/input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/input/input.c b/core/input/input.c index e843a88380..9fdd77ddd0 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -1324,6 +1324,7 @@ static mp_cmd_t *interpret_key(struct input_ctx *ictx, int code) if (ictx->key_down[j] == code) break; } + bool emit_key = false; bool doubleclick = MP_KEY_IS_MOUSE_BTN_DBL(code); if (doubleclick) { int btn = code - MP_MOUSE_BTN0_DBL + MP_MOUSE_BTN0; @@ -1332,8 +1333,8 @@ static mp_cmd_t *interpret_key(struct input_ctx *ictx, int code) return NULL; j = ictx->num_key_down - 1; ictx->key_down[j] = code; + emit_key = true; } - bool emit_key = ictx->last_key_down; if (j == ictx->num_key_down) { // was not already down; add temporarily if (ictx->num_key_down > MP_MAX_KEY_DOWN) { mp_tmsg(MSGT_INPUT, MSGL_ERR, "Too many key down events " -- cgit v1.2.3