Repository navigation
feat: lastInputMs answers the session's idle time from CGEventSource, synchronously on any thread, so react-x11's useIdle reads it from the bridge where it shelled out to ioreg for HIDIdleTime - #122
Merged
Conversation
… synchronously on any thread, so react-x11's useIdle reads it from the bridge where it shelled out to ioreg for HIDIdleTime (sidorares/react-x11#951)
…ding one by the other, since on CI's VMs lastInputMs ran 3-5 s longer
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.
The bridge follow-up from sidorares/react-x11#951.
useIdleon macOS now usesnative.lastInputMs()when the bridge has it, and shells out toioreg … HIDIdleTime(a child per poll) otherwise. With this shipped, react-x11 needs no JS change.native.lastInputMs(): number: milliseconds since the last keyboard, mouse, trackpad or tablet event in the login session, from any app. It isCGEventSourceSecondsSinceLastEventType(kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType) * 1000.initApp, in pump mode, and from a worker with the main thread inrunMain. It's listed in the README's "unchanged, on the calling thread" row.ioreg'sHIDIdleTime. The two are kept separately: they agree at a desk, but on CI's VMslastInputMsran 3–5 s longer.Test:
test/last-input.jsis innpm testand CI. A test can't make or withhold the user's input, so it checks only what holds either way:initApp, it returns a finite number ≥ 0.HIDIdleTimebesidelastInputMsfor comparison, without asserting anything about the two.runMain, it returns a number synchronously.Docs: a README section "Idle time (an empty desk)".