void Watcher::onTimeout() { xcb_screensaver_query_info_cookie_t cookie; xcb_screensaver_query_info_reply_t *info; cookie = xcb_screensaver_query_info (connection, screen->root); info = xcb_screensaver_query_info_reply (connection, cookie, NULL); uint32_t idle = info->ms_since_user_input; free (info); QSettings settings("qslsaver", "qslsaver"); bool enabled = settings.value("enabled", 1).toBool(); if (!enabled) return; int time = settings.value("timeout", 10).toInt() * 60000; if (idle <= time) return; stop(); emit(idling()); }
void X11IdleDetector::checkIdleness() { xcb_screensaver_query_info_cookie_t cookie; cookie = xcb_screensaver_query_info(m_connection, m_screen->root); xcb_screensaver_query_info_reply_t *info; info = xcb_screensaver_query_info_reply(m_connection, cookie, NULL); //krazy:exclude=null const int idleSecs = info->ms_since_user_input / 1000; free(info); if (idleSecs >= idlenessDuration()) maybeIdle(IdlePeriod(QDateTime::currentDateTime().addSecs(-idleSecs), QDateTime::currentDateTime())); if (m_heartbeat.secsTo(QDateTime::currentDateTime()) > idlenessDuration()) maybeIdle(IdlePeriod(m_heartbeat, QDateTime::currentDateTime())); m_heartbeat = QDateTime::currentDateTime(); }