From 5fcbe1c417119b5e9ed40cc990416fbf16999bd3 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Thu, 6 Jun 2024 01:09:25 -0400 Subject: [PATCH] command: add canceled state to key-binding client message This allows libmpv clients to know whether the key binding is canceled and thus should normally be ignored. --- DOCS/man/input.rst | 5 ++++- player/command.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 46b6c4cde7..0fc0619a11 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -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. diff --git a/player/command.c b/player/command.c index cabd517331..ddf5c7dd4a 100644 --- a/player/command.c +++ b/player/command.c @@ -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;