summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mpvcore/command.c29
-rw-r--r--mpvcore/input/input.c4
-rw-r--r--mpvcore/input/input.h1
3 files changed, 29 insertions, 5 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index edd4f7b634..f20a6517b8 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -2347,6 +2347,20 @@ static void overlay_uninit(struct MPContext *mpctx){}
#endif
+// Whether this property should react to key events generated by auto-repeat.
+static bool check_property_autorepeat(char *property, struct MPContext *mpctx)
+{
+ struct m_option prop = {0};
+ if (mp_property_do(property, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
+ return true;
+
+ // This is a heuristic at best.
+ if (prop.type == &m_option_type_flag || prop.type == &m_option_type_choice)
+ return false;
+
+ return true;
+}
+
void run_command(MPContext *mpctx, mp_cmd_t *cmd)
{
struct MPOpts *opts = mpctx->opts;
@@ -2417,16 +2431,23 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
};
if (cmd->args[1].v.d)
s.inc = cmd->args[1].v.d * cmd->scale;
- int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_SWITCH, &s, mpctx);
+ char *property = cmd->args[0].v.s;
+ if (cmd->repeated && !check_property_autorepeat(property, mpctx)) {
+ mp_msg(MSGT_CPLAYER, MSGL_V,
+ "Dropping command '%.*s' from auto-repeated key.\n",
+ BSTR_P(cmd->original));
+ break;
+ }
+ int r = mp_property_do(property, M_PROPERTY_SWITCH, &s, mpctx);
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
- show_property_osd(mpctx, cmd->args[0].v.s, cmd->on_osd);
+ show_property_osd(mpctx, property, cmd->on_osd);
} else if (r == M_PROPERTY_UNKNOWN) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration,
- "Unknown property: '%s'", cmd->args[0].v.s);
+ "Unknown property: '%s'", property);
} else if (r <= 0) {
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration,
"Failed to increment property '%s' by %g",
- cmd->args[0].v.s, s.inc);
+ property, s.inc);
}
break;
}
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index b26f2d491d..5b74f1aa33 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -1877,8 +1877,10 @@ mp_cmd_t *mp_input_get_cmd(struct input_ctx *ictx, int time, int peek_only)
struct cmd_queue *queue = &ictx->cmd_queue;
if (!queue->first) {
struct mp_cmd *repeated = check_autorepeat(ictx);
- if (repeated)
+ if (repeated) {
+ repeated->repeated = true;
queue_add_tail(queue, repeated);
+ }
}
struct mp_cmd *ret = queue_peek(queue);
if (ret && !peek_only) {
diff --git a/mpvcore/input/input.h b/mpvcore/input/input.h
index dc308ff9f6..3e8da7eb75 100644
--- a/mpvcore/input/input.h
+++ b/mpvcore/input/input.h
@@ -154,6 +154,7 @@ typedef struct mp_cmd {
bstr original;
char *input_section;
bool key_up_follows;
+ bool repeated;
bool mouse_move;
int mouse_x, mouse_y;
struct mp_cmd *queue_next;