diff options
Diffstat (limited to 'mpvcore/command.c')
-rw-r--r-- | mpvcore/command.c | 29 |
1 files changed, 25 insertions, 4 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; } |