1 | /* This file is part of the KDE libraries |
---|---|
2 | * SPDX-FileCopyrightText: 2009 Dario Freddi <drf at kde.org> |
3 | * |
4 | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | */ |
6 | |
7 | #ifndef KWINDOWBASEDIDLETIMEPOLLER_P_H |
8 | #define KWINDOWBASEDIDLETIMEPOLLER_P_H |
9 | |
10 | #include <kidletime_export.h> |
11 | |
12 | #include "kabstractidletimepoller_p.h" |
13 | |
14 | class QTimer; |
15 | class QEvent; |
16 | class QWindow; |
17 | |
18 | class KIDLETIME_EXPORT KWindowBasedIdleTimePoller : public KAbstractIdleTimePoller |
19 | { |
20 | Q_OBJECT |
21 | |
22 | public: |
23 | explicit KWindowBasedIdleTimePoller(QObject *parent = nullptr); |
24 | ~KWindowBasedIdleTimePoller() override; |
25 | |
26 | bool isAvailable() override; |
27 | bool setUpPoller() override; |
28 | void unloadPoller() override; |
29 | |
30 | QList<int> timeouts() const override; |
31 | |
32 | protected: |
33 | bool eventFilter(QObject *object, QEvent *event) override; |
34 | |
35 | public Q_SLOTS: |
36 | void addTimeout(int nextTimeout) override; |
37 | void removeTimeout(int nextTimeout) override; |
38 | |
39 | int forcePollRequest() override; |
40 | void catchIdleEvent() override; |
41 | void stopCatchingIdleEvents() override; |
42 | |
43 | private Q_SLOTS: |
44 | int poll(); |
45 | virtual int getIdleTime() = 0; |
46 | void detectedActivity(); |
47 | void waitForActivity(); |
48 | void releaseInputLock(); |
49 | |
50 | private: |
51 | virtual bool additionalSetUp() = 0; |
52 | |
53 | private: |
54 | QTimer *m_pollTimer; |
55 | QWindow *m_grabber; |
56 | QList<int> m_timeouts; |
57 | }; |
58 | |
59 | #endif /* KWINDOWBASEDIDLETIMEPOLLER_P_H */ |
60 |