Skip to main content

should_defer_for_typing

Function should_defer_for_typing 

Source
pub fn should_defer_for_typing(
    enabled: bool,
    idle_secs: Option<u64>,
    grace_secs: u64,
    deferred_since: Option<Instant>,
    max_deferral_secs: u64,
    now: Instant,
) -> bool
Expand description

Decide whether a due break should be delayed because the user is mid-keystroke. Returns true while we should keep waiting and false once either the user has paused typing OR the deferral cap has been reached (so we don’t postpone indefinitely).

idle_secs is None when idle detection is unavailable this tick (e.g. Wayland exposes no portable HID-idle query, so the probe keeps failing). We can’t tell whether the user is typing then, so we don’t defer — otherwise the “is the user idle?” proxy is permanently 0 and every break stalls for the full deferral cap before appearing (#67).

deferred_since is the instant the current defer-streak started, or None if this is the first tick of the streak.