Skip to content

Commit

Permalink
command: add canceled state to key-binding client message
Browse files Browse the repository at this point in the history
This allows libmpv clients to know whether they key binding is canceled
and thus should normally be ignored.
  • Loading branch information
na-na-hi committed Jun 6, 2024
1 parent 4497fb7 commit 2eff29c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1344,13 +1344,16 @@ Input Commands that are Possibly Subject to Change
key with a letter is normally not emitted as having a modifier, and results
in upper case text instead, but some backends may mess up).

The key state consists of 2 characters:
The key state consists of 3 characters:

1. One of ``d`` (key was pressed down), ``u`` (was released), ``r`` (key
is still down, and was repeated; only if key repeat is enabled for this
binding), ``p`` (key was pressed; happens if up/down can't be tracked).
2. Whether the event originates from the mouse, either ``m`` (mouse button)
or ``-`` (something else).
3. Whether the event results from a cancellation (e.g. the key is logically
released but not physically released), either ``c`` (canceled) or ``-``
(something else). Not all types of cancellations set this flag.

Future versions can add more arguments and more key state characters to
support more input peculiarities.
Expand Down
3 changes: 2 additions & 1 deletion player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -6342,7 +6342,8 @@ static void cmd_script_binding(void *p)
target = space;
name = sep + 1;
}
char state[3] = {'p', incmd->is_mouse_button ? 'm' : '-'};
char state[4] = {'p', incmd->is_mouse_button ? 'm' : '-',
incmd->canceled ? 'c' : '-'};
if (incmd->is_up_down)
state[0] = incmd->repeated ? 'r' : (incmd->is_up ? 'u' : 'd');
event.num_args = 5;
Expand Down

0 comments on commit 2eff29c

Please sign in to comment.