Skip to content

Key bindings for IINA commands: clean up & remove redundant code #5012

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

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

svobs
Copy link
Contributor

@svobs svobs commented Jun 22, 2024


Description:

Now that the fix for #4567 has been merged, it's clear that a lot of code for handling key bindings for IINA commands is now redundant because most of them are now being mapped to hidden menu items. This became apparent while examining PR #5005, which is adding a new command.

To be specific, of all the commands enumerated in IINACommand.swift, I found that nearly all of them are already being mapped to menu items in MenuController.updateKeyEquivalentsFrom(), so the checks for these can be simply deleted from PlayerWindowController.handleIINACommand() and its overrides; they will never be used. I handled the remaining 5 commands as follows:

  • flip, mirror: I migrated handling for these to updateKeyEquivalentsFrom. It was easy because all the objects were already created and easily referenced there.
  • openFile and openURL: I tried migrating these to updateKeyEquivalentsFrom, but for some reason, the Option key was being added to their equivalents. Did not dig into why this was happening; just decided to leave them in handleIINACommand instead.
  • deleteCurrentFileHard: this is a less-used command, and it didn't have an NSMenuItem object in MenuController, so it would have required more code to migrate. I did move it up from MainWindowController to PlayerWindowController so that it can also be recognized in music mode. I'm assuming that was an oversight when that feature was created.

Note that this should be considered lower-priority and not merged too close to a release.

Changes:
• Remove redundant handling of IINA commands via handleIINACommand() in
  PlayerWindowController & its subclasses (no longer needed, now that
  hidden menu items are being created in MenuController).
• Move "flip" & "mirror IINA command handling into MenuController's
  updateKeyEquivalentsFrom()
• Move handling of "deleteCurrentFileHard" command from MainWindow
  into PlayerWindow so that it will also work in music mode
@svobs svobs force-pushed the pr-iina-cmd-cleanup branch from 63cc6d7 to d2c7d82 Compare July 3, 2024 05:27
@svobs
Copy link
Contributor Author

svobs commented Jul 3, 2024

Rebased and resolved conflicts.

@uiryuu
Copy link
Member

uiryuu commented Jul 3, 2024

I think it's good to merge, given that our next release will be a beta release and the changes look logical. Or do you want to deal with this short after we release the first beta (i.e. to include this in beta 2)?

@svobs
Copy link
Contributor Author

svobs commented Jul 3, 2024

I think it's good to merge, given that our next release will be a beta release and the changes look logical.

Sounds great to me. I put the disclaimer in there because I don't have much info about the project roadmap.

@uiryuu
Copy link
Member

uiryuu commented Jul 3, 2024

Found a problem when testing this out, but not introduced by this PR. I have another app which registered cmd+shift+p as a global shortcut, in IINA this is used to toggle the playlist. When I press cmd+shift+p while IINA is focused, the other app handles this shortcut. I checked the menu, the menu item for this action is enabled. Is this the intended behavior of macOS?

@lhc70000
Copy link
Member

lhc70000 commented Jul 3, 2024

@uiryuu Yes, this can happen if the event is consumed (by a event tap) before reaching IINA.

@uiryuu uiryuu merged commit 2cd6c4e into iina:develop Jul 4, 2024
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.

3 participants