File indexing completed on 2024-04-28 05:30:17

0001 /*
0002     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <kwin_export.h>
0010 
0011 #include <QTimer>
0012 
0013 namespace KWin
0014 {
0015 
0016 class KWIN_EXPORT IdleDetector : public QObject
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     explicit IdleDetector(std::chrono::milliseconds timeout, QObject *parent = nullptr);
0022     ~IdleDetector() override;
0023 
0024     void activity();
0025 
0026     bool isInhibited() const;
0027     void setInhibited(bool inhibited);
0028 
0029 Q_SIGNALS:
0030     void idle();
0031     void resumed();
0032 
0033 private:
0034     void markAsIdle();
0035     void markAsResumed();
0036 
0037     QTimer *m_timer;
0038     bool m_isIdle = false;
0039     bool m_isInhibited = false;
0040 };
0041 
0042 } // namespace KWin