fix: re-register keyboard hooks after Windows session unlock (#1213)#1301
Draft
ChristophNoetel wants to merge 3 commits intocjpais:mainfrom
Draft
fix: re-register keyboard hooks after Windows session unlock (#1213)#1301ChristophNoetel wants to merge 3 commits intocjpais:mainfrom
ChristophNoetel wants to merge 3 commits intocjpais:mainfrom
Conversation
Add infrastructure to re-create the HotkeyManager and re-register all bindings on demand. This is needed to recover from events that invalidate low-level keyboard hooks (e.g., Windows session lock). - Add ReregisterAll variant to ManagerCommand enum - Implement do_reregister_all() that drops the old manager, creates a fresh one, and re-registers all existing bindings - Handle ReregisterAll in the manager thread with fallback recovery - Expose public reregister_all() method on HandyKeysState
…1213) When Windows switches to the secure desktop (Win+L), low-level keyboard hooks installed by handy-keys are silently invalidated. This adds a session watcher thread that: - Creates a hidden message-only window - Registers for WTS_SESSION_UNLOCK notifications - Triggers ReregisterAll to recreate hooks when the user unlocks Cleanup is handled via WM_CLOSE in HandyKeysState::drop.
b43aa63 to
5a45223
Compare
Owner
|
Just wondering if this should be done in Handykeys itself rather than the app level. |
5 tasks
…el watcher Moves session-unlock hook re-registration from the Handy app into the handy-keys library (handy-computer/handy-keys#19). The library's Windows listener thread now automatically detects WTS_SESSION_UNLOCK and re-installs hooks transparently. This removes ~170 lines of app-level session watcher code: - start_session_watcher() function and wndproc_stub callback - ReregisterAll command, do_reregister_all(), reregister_all() - session_watcher_hwnd field and Drop cleanup - Win32_System_RemoteDesktop feature from Handy's Cargo.toml The handy-keys dependency now points at the fork branch temporarily until the upstream PR is merged and published to crates.io. Addresses cjpais's review feedback on cjpais#1301.
Contributor
Author
|
Good call -- you're right that hook lifecycle is a library concern. I've moved the session recovery into handy-keys itself: handy-computer/handy-keys#19. The library's Windows listener thread already runs a message pump, good fit^^ . On startup it creates a message-only window, registers for This PR now just points |
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 #1213 -- Windows screen lock (Win+L) kills
handy-keyskeyboard shortcuts because the Winlogon desktop switch invalidates low-level hooks, and the manager thread never re-registers them.This PR adds:
ReregisterAllcommand to the handy-keys manager thread that drops the oldHotkeyManager, creates a fresh one, and re-registers all bindingsreregister_all()method onHandyKeysStatefor triggering re-registrationComing next (will push before marking ready):
WTS_SESSION_UNLOCK) that automatically triggersreregister_all()after lock/unlockSee my root cause analysis on the issue.
Test plan
cargo check/cargo clippypass (CI)