-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix bug when triggering some key bindings: raw mpv commands executed instead of calling IINA code #4567
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
Conversation
This is not the only mess caused by trying to add a feature on top of mpv. IINA needs to resist adding features that really belong in mpv. But we have no choice but to now try and make these features that have already been added work properly. Is using the menu the right approach? I'm not liking that it seems like we are now deviating from Apple's standard menu key binding concepts. We already have a concept of binding a key to an "IINA command". Should these keys be bound to an IINA cycle pause command? I'm still thinking on this… |
Not exactly sure what you mean by this? I definitely admit the fix in this PR is pretty hacky looking. The problem is that most of the action callbacks in @objc func menuToggleFullScreen(_ sender: NSMenuItem) {
toggleWindowFullScreen()
} So I ended up creating "dummy"
Actually I just found another case which both helps further illustrate the problem and expands the scope of this defect. Take a look at func screenshot() {
guard let vid = info.vid, vid > 0 else { return }
let saveToFile = Preference.bool(for: .screenshotSaveToFile)
let saveToClipboard = Preference.bool(for: .screenshotCopyToClipboard)
guard saveToFile || saveToClipboard else { return }
let option = Preference.bool(for: .screenshotIncludeSubtitle) ? "subtitles" : "video"
mpv.asyncCommand(.screenshot, args: [option], replyUserdata: MPVController.UserData.screenshot)
} The first key mapping for I also revisited your |
On this:
And this:
To me these are indications that this is the wrong approach. The On this:
The code in I would expect that menu processing, key press processing and button clicking all might call into some sort of common command processing. Yes, the screenshot code seems to be another case where IINA has enhanced mpv's functionality in a way that has created an "IINA command". The error when it comes to key binding is not that all keys that are bound to "screenshot" are not triggering the menu item. The error is that the key is bound to the mpv screenshot command. We want it to trigger the "enhanced" IINA screenshot command. We already have a concept of binding a key to an IINA command, On I will see if I can get the attention of other developers as they may disagree with me on this. |
There is a great need for refactoring this mechanism. But since I've made some attempts in the past which have been ignored (specifically two different approaches to #3732), I'm now striving for minimal impact on existing code. Some design speculation: Maybe a cleaner way to design it would be to:
But while this is great in principle,
Second approach: By attaching a flag + an action reference to the matched |
I'm trying to get the attention of other developers to get their thoughts on this. |
I will have a look after finishing the plugin system (one PR remaining). |
I noticed the new plugin PR. Aren't PRs 4423, 4403, 4319 about the plugin system? |
@low-batt yes, definitely will handle them before releasing 1.4.0 beta. I meant on my side I only have one remaining PR to submit. |
Sorry for my extremely late reply. I don't think modifying the How about this: create a hidden submenu somewhere (e.g. |
Definitely a more elegant solution since it will always be using Will dig in to this soon. |
According to the documentation, the order is key equivalents → keyboard interface control → keyboard action (i.e I tested locally, and a second key binding ( |
c9ef62b
to
dff8ec3
Compare
Implemented! See latest push. And yeah, looks like priority for single key bindings was not a problem. This seems to be the cleanest solution yet. |
…the first match found were sending mpv command directly instead of invoking IINA code. Create new hidden menu, File > Other Actions From Key Bindings, which is now populated with these matches, and which will appear in search results via the Help menu.
dff8ec3
to
1d97f8d
Compare
To test that this fixes issue #4582 I changed my key bindings to be I then played a video with screenshots, paused on a frame with subtitles and tried taking screenshots by typing both That issue does not seem to be fixed. |
@low-batt the "mpv Default" config has different commands bound to
It looks like the
You need to use a custom config file, and create two separate mappings for With regard to #4582, I tried the no-arg |
Issue 4582 uncovered multiple problems. We could get this PR merged and create another PR to address the remaining problems. The 4 screenshot related key bindings in
The I believe the mapping for The |
I'm not clear on what you're arguing. It sounds like there are multiple ideas:
|
On this:
No? These don't really match any menu items. I was expecting this would require a special case in the I don't think we have anything bound to Agree, IINA setting is not applicable to |
Let's merge this first and move the remaining screenshot problems to another issue. |
Description:
Fixes longstanding bug: when multiple key bindings qualify for IINA code actions, only the first match actually invokes the action. All other matches will invoke the mpv command directly instead of invoking IINA code. For some commands this will result in differences and/or missing behavior.
This is pretty deep in the trenches... See my comment here for some more explanation.
Most prominent example is the

cycle pause
action:Although this bug affected all menu items, it looks like "pause/resume" was the only one in which a difference was noticed, probably because it is the only one which deviates from mpv's behavior when executing IINA code compared to the undecorated mpv command.
EDIT: Also affects
screenshot
(see below).