aboutsummaryrefslogtreecommitdiffhomepage
path: root/input
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-07-07 18:18:41 +0200
committerGravatar wm4 <wm4@nowhere>2014-07-07 18:18:41 +0200
commit4d829d750cc872ae4e6bf31117022f8934230972 (patch)
treeec7a3855f2de23a876aba60beb5ef9582627a9e5 /input
parentc07bae02e2d0cdb32e6d4f0741ad039091f64bd7 (diff)
input: restore ability to combine mouse buttons
Key bindings are decided on the "down" event, so if the prefix is not unique, the first/shortest will be used (e.g. when both "a" and "a-b" are mapped, "a" will always be chosen). This also breaks combining multiple mouse buttons. But it seems users expect it to work, and it's indeed a bit strange that it shouldn't work, as mouse bindings are emitted on the key "up" event, not "down" (if the shorter binding didn't emit a command yet, why shouldn't it be combinable). Deal with this by clearing the key history when a command is actually emitted, instead of when a command is decided. This means if both MOUSE_BTN0 and MOUSE_BTN0-MOUSE_BTN1 are mapped, the sequence of holding down BTN0 and then BTN1 will redecide the current command. On the other hand, if BTN0 is released before BTN1 is pressed, the command is emitted, and the key history is deleted. So the BTN1 press will not trigger BTN0-BTN1. For normal keys, nothing should change, because commands are emitted on the "down" event already, so the key history is always cleared. Might fix #902. CC: @mpv-player/stable (if this fix is successful)
Diffstat (limited to 'input')
-rw-r--r--input/input.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/input/input.c b/input/input.c
index 983cb84fe3..ebcbaf208f 100644
--- a/input/input.c
+++ b/input/input.c
@@ -556,6 +556,7 @@ static void release_down_cmd(struct input_ctx *ictx, bool drop_current)
if (!drop_current && ictx->current_down_cmd &&
ictx->current_down_cmd->key_up_follows)
{
+ memset(ictx->key_history, 0, sizeof(ictx->key_history));
ictx->current_down_cmd->key_up_follows = false;
queue_add_tail(&ictx->cmd_queue, ictx->current_down_cmd);
ictx->got_new_events = true;
@@ -595,15 +596,10 @@ static struct mp_cmd *resolve_key(struct input_ctx *ictx, int code)
{
update_mouse_section(ictx);
struct mp_cmd *cmd = get_cmd_from_keys(ictx, NULL, code);
- if (cmd && cmd->id != MP_CMD_IGNORE) {
- memset(ictx->key_history, 0, sizeof(ictx->key_history));
- if (!should_drop_cmd(ictx, cmd))
- return cmd;
- talloc_free(cmd);
- return NULL;
- }
- talloc_free(cmd);
key_buf_add(ictx->key_history, code);
+ if (cmd && cmd->id != MP_CMD_IGNORE && !should_drop_cmd(ictx, cmd))
+ return cmd;
+ talloc_free(cmd);
return NULL;
}
@@ -672,6 +668,8 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale)
return;
}
+ memset(ictx->key_history, 0, sizeof(ictx->key_history));
+
cmd->scale = scale;
if (cmd->key_up_follows)