7#include "kwindowbasedidletimepoller_p.h"
13KWindowBasedIdleTimePoller::KWindowBasedIdleTimePoller(
QObject *parent)
14 : KAbstractIdleTimePoller(parent)
18KWindowBasedIdleTimePoller::~KWindowBasedIdleTimePoller()
22bool KWindowBasedIdleTimePoller::isAvailable()
27bool KWindowBasedIdleTimePoller::setUpPoller()
29 m_pollTimer =
new QTimer(
this);
36 m_grabber->setPosition(-1000, -1000);
37 m_grabber->installEventFilter(
this);
38 m_grabber->setObjectName(QStringLiteral(
"KIdleGrabberWidget"));
40 return additionalSetUp();
43void KWindowBasedIdleTimePoller::unloadPoller()
45 m_pollTimer->deleteLater();
46 m_grabber->deleteLater();
49QList<int> KWindowBasedIdleTimePoller::timeouts()
const
54void KWindowBasedIdleTimePoller::addTimeout(
int nextTimeout)
56 m_timeouts.
append(nextTimeout);
60bool KWindowBasedIdleTimePoller::eventFilter(
QObject *
object,
QEvent *event)
65 }
else if (
object != m_grabber) {
74void KWindowBasedIdleTimePoller::waitForActivity()
77 m_grabber->setMouseGrabEnabled(
true);
78 m_grabber->setKeyboardGrabEnabled(
true);
81void KWindowBasedIdleTimePoller::detectedActivity()
83 stopCatchingIdleEvents();
84 Q_EMIT resumingFromIdle();
87void KWindowBasedIdleTimePoller::releaseInputLock()
89 m_grabber->setMouseGrabEnabled(
false);
90 m_grabber->setKeyboardGrabEnabled(
false);
94int KWindowBasedIdleTimePoller::poll()
96 int idle = getIdleTime();
99 for (
int timeOut : std::as_const(m_timeouts)) {
100 if ((timeOut - idle < 300 && timeOut >= idle) || (idle - timeOut < 300 && idle > timeOut)) {
102 Q_EMIT timeoutReached(timeOut);
109 for (
int i : std::as_const(m_timeouts)) {
110 if (i > idle && (i < mintime || mintime == 0)) {
118 m_pollTimer->start(mintime - idle);
126int KWindowBasedIdleTimePoller::forcePollRequest()
131void KWindowBasedIdleTimePoller::removeTimeout(
int timeout)
133 m_timeouts.removeOne(timeout);
137void KWindowBasedIdleTimePoller::catchIdleEvent()
142void KWindowBasedIdleTimePoller::stopCatchingIdleEvents()
147#include "moc_kwindowbasedidletimepoller_p.cpp"
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
void append(QList< T > &&value)
X11BypassWindowManagerHint
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)