1/*
2 SPDX-FileCopyrightText: 2021 David Edmundson <davidedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6#pragma once
7
8#include "kabstractidletimepoller_p.h"
9
10#include <QHash>
11#include <memory>
12
13class IdleManagerKwin;
14class IdleManagerExt;
15
16class IdleTimeout;
17
18class Poller : public KAbstractIdleTimePoller
19{
20 Q_OBJECT
21 Q_PLUGIN_METADATA(IID KAbstractIdleTimePoller_iid FILE "wayland.json")
22 Q_INTERFACES(KAbstractIdleTimePoller)
23
24public:
25 explicit Poller(QObject *parent = nullptr);
26 ~Poller() override;
27
28 bool isAvailable() override;
29 bool setUpPoller() override {
30 return true;
31 }
32 void unloadPoller() override {}
33
34public Q_SLOTS:
35 void addTimeout(int nextTimeout) override;
36 void removeTimeout(int nextTimeout) override;
37 QList<int> timeouts() const override;
38 int forcePollRequest() override;
39 void catchIdleEvent() override;
40 void stopCatchingIdleEvents() override;
41 void simulateUserActivity() override;
42
43private:
44 bool initWayland();
45 IdleTimeout* createTimeout(int timeout);
46
47 QScopedPointer<IdleManagerKwin> m_idleManagerKwin;
48 QScopedPointer<IdleManagerExt> m_idleManagerExt;
49 QHash<int, QSharedPointer<IdleTimeout>> m_timeouts;
50 QScopedPointer<IdleTimeout> m_catchResumeTimeout;
51
52};
53

source code of kidletime/src/plugins/wayland/poller.h