summaryrefslogtreecommitdiffstats
path: root/input/input.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-20 15:31:25 +0200
committerwm4 <wm4@nowhere>2016-09-20 15:44:11 +0200
commitbf385e1140069fb1c6d41161aece0fe099513ac0 (patch)
treebebb5b971fa22a2d15992cecbd9a501b09b2e1b5 /input/input.c
parentfe872f56884a3a5c506d49d9601713d0e6de1973 (diff)
downloadmpv-bf385e1140069fb1c6d41161aece0fe099513ac0.tar.bz2
mpv-bf385e1140069fb1c6d41161aece0fe099513ac0.tar.xz
player: kill associated OSD and key bindings when removing a script
The former was done already for Lua scripts, but move it to the generic code.
Diffstat (limited to 'input/input.c')
-rw-r--r--input/input.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/input/input.c b/input/input.c
index 90cd439779..da1f85b829 100644
--- a/input/input.c
+++ b/input/input.c
@@ -73,6 +73,7 @@ struct cmd_bind {
};
struct cmd_bind_section {
+ char *owner;
struct cmd_bind *binds;
int num_binds;
char *section;
@@ -1009,13 +1010,19 @@ static void remove_binds(struct cmd_bind_section *bs, bool builtin)
}
void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,
- char *contents, bool builtin)
+ char *contents, bool builtin, char *owner)
{
if (!name || !name[0])
return; // parse_config() changes semantics with restrict_section==empty
input_lock(ictx);
// Delete:
struct cmd_bind_section *bs = get_bind_section(ictx, bstr0(name));
+ if ((!bs->owner || (owner && strcmp(bs->owner, owner) != 0)) &&
+ strcmp(bs->section, "default") != 0)
+ {
+ talloc_free(bs->owner);
+ bs->owner = talloc_strdup(bs, owner);
+ }
remove_binds(bs, builtin);
if (contents && contents[0]) {
// Redefine:
@@ -1027,6 +1034,21 @@ void mp_input_define_section(struct input_ctx *ictx, char *name, char *location,
input_unlock(ictx);
}
+void mp_input_remove_sections_by_owner(struct input_ctx *ictx, char *owner)
+{
+ input_lock(ictx);
+ struct cmd_bind_section *bs = ictx->cmd_bind_sections;
+ while (bs) {
+ if (bs->owner && owner && strcmp(bs->owner, owner) == 0) {
+ mp_input_disable_section(ictx, bs->section);
+ remove_binds(bs, false);
+ remove_binds(bs, true);
+ }
+ bs = bs->next;
+ }
+ input_unlock(ictx);
+}
+
static bool bind_matches_key(struct cmd_bind *bind, int num_keys, const int *keys)
{
if (bind->num_keys != num_keys)