File indexing completed on 2024-04-28 03:54:39

0001 /* This file is part of the KDE libraries
0002  * SPDX-FileCopyrightText: 2009 Dario Freddi <drf at kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #ifndef KWINDOWBASEDIDLETIMEPOLLER_P_H
0008 #define KWINDOWBASEDIDLETIMEPOLLER_P_H
0009 
0010 #include <kidletime_export.h>
0011 
0012 #include "kabstractidletimepoller_p.h"
0013 
0014 class QTimer;
0015 class QEvent;
0016 class QWindow;
0017 
0018 class KIDLETIME_EXPORT KWindowBasedIdleTimePoller : public KAbstractIdleTimePoller
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     explicit KWindowBasedIdleTimePoller(QObject *parent = nullptr);
0024     ~KWindowBasedIdleTimePoller() override;
0025 
0026     bool isAvailable() override;
0027     bool setUpPoller() override;
0028     void unloadPoller() override;
0029 
0030     QList<int> timeouts() const override;
0031 
0032 protected:
0033     bool eventFilter(QObject *object, QEvent *event) override;
0034 
0035 public Q_SLOTS:
0036     void addTimeout(int nextTimeout) override;
0037     void removeTimeout(int nextTimeout) override;
0038 
0039     int forcePollRequest() override;
0040     void catchIdleEvent() override;
0041     void stopCatchingIdleEvents() override;
0042 
0043 private Q_SLOTS:
0044     int poll();
0045     virtual int getIdleTime() = 0;
0046     void detectedActivity();
0047     void waitForActivity();
0048     void releaseInputLock();
0049 
0050 private:
0051     virtual bool additionalSetUp() = 0;
0052 
0053 private:
0054     QTimer *m_pollTimer;
0055     QWindow *m_grabber;
0056     QList<int> m_timeouts;
0057 };
0058 
0059 #endif /* KWINDOWBASEDIDLETIMEPOLLER_P_H */