Files
RedBear-OS/local/recipes/kde/kwin/source/src/idledetector.cpp
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

85 lines
1.4 KiB
C++

/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "idledetector.h"
#include "input.h"
using namespace std::chrono_literals;
namespace KWin
{
IdleDetector::IdleDetector(std::chrono::milliseconds timeout, QObject *parent)
: QObject(parent)
, m_timeout(timeout)
{
Q_ASSERT(timeout >= 0ms);
m_timer.start(timeout, this);
input()->addIdleDetector(this);
}
IdleDetector::~IdleDetector()
{
if (input()) {
input()->removeIdleDetector(this);
}
}
void IdleDetector::timerEvent(QTimerEvent *event)
{
if (event->timerId() == m_timer.timerId()) {
m_timer.stop();
markAsIdle();
}
}
bool IdleDetector::isInhibited() const
{
return m_isInhibited;
}
void IdleDetector::setInhibited(bool inhibited)
{
if (m_isInhibited == inhibited) {
return;
}
m_isInhibited = inhibited;
if (inhibited) {
m_timer.stop();
} else {
m_timer.start(m_timeout, this);
}
}
void IdleDetector::activity()
{
if (!m_isInhibited) {
m_timer.start(m_timeout, this);
markAsResumed();
}
}
void IdleDetector::markAsIdle()
{
if (!m_isIdle) {
m_isIdle = true;
Q_EMIT idle();
}
}
void IdleDetector::markAsResumed()
{
if (m_isIdle) {
m_isIdle = false;
Q_EMIT resumed();
}
}
} // namespace KWin
#include "moc_idledetector.cpp"