mirror of
https://github.com/mpv-player/mpv
synced 2024-12-20 22:02:59 +00:00
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)
This commit is contained in:
parent
c07bae02e2
commit
4d829d750c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user