fix: re-enable disabled macOS event taps - #1420
Open
shyam-king wants to merge 1 commit into
Open
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
Fixes #1419. On macOS,
CGEventTapis disabled by the system when its callback is too slow to respond (kCGEventTapDisabledByTimeout) or on certain user-input conditions (kCGEventTapDisabledByUserInput), most commonly around sleep/wake. Neither the keyboard hook nor the mouse listener handled these notifications, so once a tap was disabled it stayed disabled for the rest of the process lifetime — keybindings (and mouse events) would silently stop working until GlazeWM was restarted.This adds a shared
EventTapHandle(wm-platform/src/platform_impl/macos/event_tap.rs) that:CFMachPort, set up before the run loop source is registered.TapDisabledByTimeout/TapDisabledByUserInputevent in either callback, callsCGEventTap::tap_enable(tap_port, true)to re-enable the tap and logs awarn!with the reason, short-circuiting normal event processing for that callback invocation.error!if the tap handle can't be accessed, so failures aren't silent.Wired into both
keyboard_hook.rsandmouse_listener.rs, which share the same tap lifecycle pattern.Testing
reason="callback timeout"), with no keybinding freeze observed — previously this reproduced within ~1.5 days of uptime.event_tap.rscovering disable-notification detection vs. normal event pass-through.cargo test -p wm-platformpasses.Test plan