Fix global hotkey matching and event suppression#2
Draft
6BlackCats6 wants to merge 7 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HotkeyManagerCGEventtapRoot cause
The running app creates
SimpleAppDelegate, which in turn ownedHotkeyManager. The stored shortcut included the main key code, but runtime matching only compared modifiers and was evaluated fromflagsChanged. As a result, pressing Command alone matched Command+Space. The activeNSEventglobal monitor also could not suppress the foreground application's original event.The new event processor requires an exact modifier-and-key-code match for ordinary shortcuts. The manager uses a default
CGEventtap and returnsnilfor matched events, so they are not delivered to the foreground app. Modifier-only shortcuts continue to use press/release transitions and remain pass-through.Tests
The XCTest suite covers:
Validation completed on this host:
git diff --checkpassedEnvironment limitations
This host has only Apple Command Line Tools, so the XCTest target and full
xcodebuildcannot run here without a full Xcode installation. A live end-to-end event-tap suppression check also requires a logged-in macOS GUI session with Accessibility permission.