summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-07 18:18:41 +0200
committerAlessandro Ghedini <alessandro@ghedini.me>2014-07-08 10:11:07 +0200
commitb18c2d9fe2a83cb93e4f9439641ef745af6e56c6 (patch)
tree0c4a8b194636dc46b306d3175f739bc6be79b5b8
parent8f5ebdbe59637b8ef2388a7705b72fedc5fe8243 (diff)
downloadmpv-b18c2d9fe2a83cb93e4f9439641ef745af6e56c6.tar.bz2
mpv-b18c2d9fe2a83cb93e4f9439641ef745af6e56c6.tar.xz
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)
-rw-r--r--input/input.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/input/input.c b/input/input.c
index 212a6ff92d..ffe170341e 100644
--- a/input/input.c
+++ b/input/input.c
@@ -557,6 +557,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;
@@ -596,15 +597,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;
}
@@ -673,6 +669,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)