2021-10-18 18:34:40 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <kwin_export.h>
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class KWIN_EXPORT IdleDetector : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit IdleDetector(std::chrono::milliseconds timeout, QObject *parent = nullptr);
|
|
|
|
~IdleDetector() override;
|
|
|
|
|
|
|
|
void activity();
|
|
|
|
|
|
|
|
bool isInhibited() const;
|
|
|
|
void setInhibited(bool inhibited);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void idle();
|
|
|
|
void resumed();
|
|
|
|
|
|
|
|
private:
|
2022-06-30 06:51:05 +00:00
|
|
|
void markAsIdle();
|
|
|
|
void markAsResumed();
|
|
|
|
|
2021-10-18 18:34:40 +00:00
|
|
|
QTimer *m_timer;
|
2022-06-30 06:51:05 +00:00
|
|
|
bool m_isIdle = false;
|
2021-10-18 18:34:40 +00:00
|
|
|
bool m_isInhibited = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|