File indexing completed on 2024-11-10 04:56:59

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 
0011 #include <QHash>
0012 #include <QTimer>
0013 #include <private/kabstractidletimepoller_p.h>
0014 
0015 namespace KWin
0016 {
0017 
0018 class IdleDetector;
0019 
0020 class KWinIdleTimePoller : public KAbstractIdleTimePoller
0021 {
0022     Q_OBJECT
0023     Q_PLUGIN_METADATA(IID KAbstractIdleTimePoller_iid FILE "kwin.json")
0024     Q_INTERFACES(KAbstractIdleTimePoller)
0025 
0026 public:
0027     KWinIdleTimePoller(QObject *parent = nullptr);
0028 
0029     bool isAvailable() override;
0030     bool setUpPoller() override;
0031     void unloadPoller() override;
0032 
0033 public Q_SLOTS:
0034     void addTimeout(int nextTimeout) override;
0035     void removeTimeout(int nextTimeout) override;
0036     QList<int> timeouts() const override;
0037     int forcePollRequest() override;
0038     void catchIdleEvent() override;
0039     void stopCatchingIdleEvents() override;
0040     void simulateUserActivity() override;
0041 
0042 private:
0043     IdleDetector *m_catchResumeTimeout = nullptr;
0044     QHash<int, IdleDetector *> m_timeouts;
0045 };
0046 
0047 }