// Idle tracking for the auto-lock: pure, header-only, main-thread only. #pragma once #include namespace dragonx { namespace util { class IdleTracker { public: using Clock = std::chrono::steady_clock; explicit IdleTracker(Clock::time_point start = Clock::now()) : last_(start) {} // Never moves backwards (an event stamped before the last one must not shorten the idle time). void noteActivity(Clock::time_point t = Clock::now()) { if (t > last_) last_ = t; } double idleSeconds(Clock::time_point now = Clock::now()) const { return now <= last_ ? 0.0 : std::chrono::duration(now - last_).count(); } private: Clock::time_point last_; }; } // namespace util } // namespace dragonx