LASTINPUTINFO LastInput = {};
LastInput.cbSize = sizeof(LastInput);
::GetLastInputInfo(&LastInput);
uint IdleTime = (::GetTickCount() - LastInput.dwTime)/1000;
int EventBase = 0;
int ErrorBase = 0;
uint IdleTime = 0;
if (::XScreenSaverQueryExtension(m_pDisplay, &EventBase, &ErrorBase))
{
XScreenSaverInfo* pInfo = ::XScreenSaverAllocInfo();
if (pInfo)
{
::XScreenSaverQueryInfo(::XOpenDisplay(NULL), DefaultRootWindow(m_pDisplay), pInfo);
IdleTime = static_cast<uint>(pInfo->idle)/1000;
::XFree(pInfo);
}
}
CFTimeInterval Interval = CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateHIDSystemState,
kCGAnyInputEventType);
return static_cast<uint>(Interval);