Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: new option: --no-input-builtin-bindings #9284

Closed
wants to merge 2 commits into from

Conversation

avih
Copy link
Member

@avih avih commented Oct 7, 2021

This is similar to [no-]input-default-bindings, but affects only
builtin bindings (while input-default-bindings affects anything which
config files can override, like scripting mp.add_key_binding).

Arguably, this is what input-default-binding should have always done,
however, it does not.

The reason we add a new option rather than repurpose/modify the
existing option is that it behaves differently enough to raise
concerns that it will break some use cases for existing users:

  • The existing option is runtime, while the new option is startup-only.
  • The bindings set affected by the existing option can still be useful.

Implementation-wise, both options are trivial, so keeping one or the
other or both doesn't affect code complexity.

More info at the commit message.

Fixes #8809

@avih
Copy link
Member Author

avih commented Oct 7, 2021

As requested by @jeeb : reword the new option docs, add a note to interface-changes, move the input-default-bindings docs update to a new commit. (code and commit message unmodified)

This is similar to [no-]input-default-bindings, but affects only
builtin bindings (while input-default-bindings affects anything which
config files can override, like scripting mp.add_key_binding).

Arguably, this is what input-default-binding should have always done,
however, it does not.

The reason we add a new option rather than repurpose/modify the
existing option is that it behaves differently enough to raise
concerns that it will break some use cases for existing users:
- The new option is only applied once on startup, while
  input-default-bindings can be modified effectively at runtime.
- They affects different sets of bindings, and it's possible that
  the set of input-default-bindings is useful enough to keep.

Implementation-wise, both options are trivial, so keeping one or the
other or both doesn't affect code complexity.

It could be argued that it would be useful to make the new option
also effective for runtime changes, however, this opens a can of
worms of how the bindings are stored beyond the initial setup.

TL;DR: it's impossible to differentiate correctly at runtime between
builtin bindings, and those added with mp.add_key_bindings.

The gist is that technically mpv needs/uses two binding "classes":
- weak/builtin bindings - lower priority than config files.
- "user" bindings - config files and "forced" runtime bindings.

input-default-bindings affects the first class trivially, but
input-builtin-bindings would not be able split this class further
at runtime without meaningful changes to a lot of delicate code.

So a new option it is. It should be useful to some libmpv clients
(players) which want to disable mpv's builtin bindings without
breaking mp.add_key_bindings for scripts.

Fixes mpv-player#8809
(again. the previous fix 8edfe70 only improved the docs, while
now we're actually making the requested behavior possible)
@avih
Copy link
Member Author

avih commented Oct 8, 2021

Force-pushed docs capitalization typo at the first commit ("and If used" -> "and if used") and rebased.

Copy link
Member

@jeeb jeeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very slight note regarding interface-changes.rst, otherwise LGTM since I can see this option being utilized in f.ex. mpvnet-player/mpv.net#271 .

@@ -43,6 +43,7 @@ Interface changes
- add a `--watch-later-options` option to allow configuring which
options quit-watch-later saves
- make `current-window-scale` writeable and use it in the default input.conf
- new startup-only option --no-input-builtin-bindings (useful with libmpv).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking at the nearby lines:

  • the wording add xyz is generally utilized here
  • the flags/options are surrounded by backticks
  • additionally, since this lists the interface changes it might make sense to strip/mark the no- prefix, as it is just part of the auto-generation of things for cli options - which stopped working through libmpv since circa 0.26?

(mpv_set_option_string(mpv_ctx, "input-builtin-bindings", "no"); would be how an API user would utilize this methinks (before init and after creation of context))

- add `--(no-)input-builtin-bindings` flag to control loading of built-in key bindings during start-up.

The previous few flags have all been off by default so we have not had to think about how to best describe enabled by default flags in here, so I'm open to how exactly it's done. But this is what came out of my mind right now.

@avih
Copy link
Member Author

avih commented Oct 11, 2021

Thanks, pushed to master as a3ef4c6

interfaces-changes text changed from:

- add `--(no-)input-builtin-bindings` flag to control loading of built-in key
  bindings during start-up.

to

- add `--input-builtin-bindings` flag to control loading of built-in key
  bindings during start-up (default: yes).

as agreed on IRC.

@avih avih closed this Oct 11, 2021
@avih avih deleted the input-builtin-bindings branch October 11, 2021 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--no-input-default-bindings: docs different than behavior
2 participants