From b9eaafe1ed4f38efcd08d113d9e51e9ebb034f6e Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 25 Apr 2011 14:12:04 +0300 Subject: input: modify interpretation of doubleclick events The code combining button presses into multibutton commands prevented single click commands from triggering if a doubleclick event had been generated from the same button press. As a result using the mouse wheel to seek worked very badly. Special-case doubleclick events in the event interpretation code to avoid this issue. This changes the sequence of generated "keys" for press-release-press-release from MOUSE_BTN0 MOUSE_BTN0-MOUSE_BTN0_DBL MOUSE_BTN0_DBL to MOUSE_BTN0 MOUSE_BTN0_DBL MOUSE_BTN0. "Keys" like MOUSE_BTN0-MOUSE_BTN0_DBL will never be generated now; any existing configuration files using those need to be changed. --- input/input.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'input/input.c') diff --git a/input/input.c b/input/input.c index ccce08e450..4c69d00400 100644 --- a/input/input.c +++ b/input/input.c @@ -1184,6 +1184,15 @@ static mp_cmd_t *interpret_key(struct input_ctx *ictx, int code) if (ictx->key_down[j] == code) break; } + bool doubleclick = code >= MOUSE_BTN0_DBL && code < MOUSE_BTN_DBL_END; + if (doubleclick) { + int btn = code - MOUSE_BTN0_DBL + MOUSE_BTN0; + if (!ictx->num_key_down + || ictx->key_down[ictx->num_key_down - 1] != btn) + return NULL; + j = ictx->num_key_down - 1; + ictx->key_down[j] = code; + } 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 " @@ -1198,6 +1207,10 @@ static mp_cmd_t *interpret_key(struct input_ctx *ictx, int code) ret = ictx->last_key_down ? get_cmd_from_keys(ictx, ictx->num_key_down, ictx->key_down) : NULL; + if (doubleclick) { + ictx->key_down[j] = code - MOUSE_BTN0_DBL + MOUSE_BTN0; + return ret; + } // Remove the key if (j + 1 < ictx->num_key_down) memmove(&ictx->key_down[j], &ictx->key_down[j + 1], -- cgit v1.2.3