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

fix: global shortcut media keys working with accessibility #24145

Merged
merged 2 commits into from Aug 24, 2020

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Jun 16, 2020

Description of Change

Closes #24052.

Initially, I tried to fix this in #21442, by patching out Chromium's usage of RemoteCommandCenterDelegate entirely, as it uses MPRemoteCommandCenter in a change added in this CL. MPRemoteCommandCenter makes it such that globalShortcuts in Electron will not work as intended, because by design an app does not receive remote control events until it begins playing audio. However, as of macOS Catalina, the alternate implementation requires accessibility access to have been granted, which means that it created a situation where simply trying to watch a YouTube video and hitting play/pause would trigger Electron to request a user for Accessibility permissions. For many large apps this is extremely undesirable behavior.

This second-pass solution splits the difference. What we want is for unilateral override only when registering globalShortcuts, which means disabling internal media key handling specifically in that use case. Chromium's media key listener manager already kept track of media_key_handling_enabled as a member, so I added a new static method to GlobalShortcutListenerMac that allows us to enable and disable it when registering and unregistering shortcuts. Then, we can ensure it's off when registering global shortcuts, and on otherwise (preserving previous behavior).

Tested with https://gist.github.com/codebytere/a7e33c6f03a84dbcc2878859237422dd.

cc @MarshallOfSound @ckerr @zcbenz

Checklist

Release Notes

Notes: Fixed media keys working unilaterally when registered with globalShortcut

@codebytere codebytere requested a review from a team as a code owner June 16, 2020 05:45
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 16, 2020
@codebytere codebytere changed the title fix: global shortcut media keys fix: global shortcut media keys working with accessibilty Jun 16, 2020
@codebytere codebytere changed the title fix: global shortcut media keys working with accessibilty fix: global shortcut media keys working with accessibility Jun 16, 2020
@codebytere codebytere force-pushed the media-key-fix-accel branch 4 times, most recently from 6f679ce to b19407f Compare June 16, 2020 16:36
@codebytere codebytere force-pushed the media-key-fix-accel branch 3 times, most recently from ff45ef9 to 9ae76b7 Compare June 16, 2020 19:20
@codebytere codebytere requested review from ckerr and zcbenz June 16, 2020 20:54
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jun 17, 2020
Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

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

Just blocking temporarily until I can test this out a bit. Just want some manual sanity checks on the expected behavior here

@somebeaver
Copy link

somebeaver commented Jul 23, 2020

@MarshallOfSound Hello, I do not mean to pester, I am just looking for an update on if this will be merged soon, as it has been manually blocked for about a month. Thank you :)

@codebytere codebytere merged commit 0efcaec into master Aug 24, 2020
@release-clerk
Copy link

release-clerk bot commented Aug 24, 2020

Release Notes Persisted

Fixed media keys working unilaterally when registered with globalShortcut

@codebytere codebytere deleted the media-key-fix-accel branch August 24, 2020 17:41
@trop
Copy link
Contributor

trop bot commented Aug 24, 2020

I was unable to backport this PR to "10-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot removed the target/10-x-y label Aug 24, 2020
@trop
Copy link
Contributor

trop bot commented Aug 24, 2020

I was unable to backport this PR to "9-x-y" cleanly;
you will need to perform this backport manually.

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.

Media Keys not working when registered with globalShortcut
4 participants