0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 19:42:24 +02:00

input: prioritize builtin bindings matching longer key sequences

This fixes 2 different bugs:

- mp.add_key_binding('c', ...) taking priority over the builtin g-c
  binding.

This follows up 994a08f5a7 which fixed this within the same input
section. This fixes it across different input sections.

- mp.add_key_binding('g-c', ...) not taking priority over a c binding
  defined in input.conf.

This happened because is_builtin of bindings added with
mp.add_key_binding is true though they're not actually builtin.
This commit is contained in:
Guido Cella 2024-05-17 02:39:16 +02:00 committed by Kacper Michajłow
parent 5e65999eb2
commit 3f83671f20

View File

@ -452,8 +452,12 @@ static struct cmd_bind *find_any_bind_for_key(struct input_ctx *ictx,
ictx->mouse_vo_x,
ictx->mouse_vo_y)))
{
if (!best_bind || (best_bind->is_builtin && !bind->is_builtin))
if (!best_bind || bind->num_keys > best_bind->num_keys ||
(best_bind->is_builtin && !bind->is_builtin &&
bind->num_keys == best_bind->num_keys))
{
best_bind = bind;
}
}
}
if (s->flags & MP_INPUT_EXCLUSIVE)