KIdleTime

xsyncbasedpoller.h
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 XSYNCBASEDPOLLER_H
8 #define XSYNCBASEDPOLLER_H
9 
10 #include "abstractsystempoller.h"
11 #include <QHash>
12 
13 #include <config-kidletime.h>
14 
15 #include <X11/Xlib.h>
16 #include <X11/extensions/sync.h>
17 #include <xcb/xcb.h>
18 
19 #include "fixx11h.h"
20 
21 class XSyncBasedPoller : public AbstractSystemPoller
22 {
23  Q_OBJECT
24  Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "xcb.json")
25  Q_INTERFACES(AbstractSystemPoller)
26 
27 public:
28  static XSyncBasedPoller *instance();
29 
30  explicit XSyncBasedPoller(QObject *parent = nullptr);
31  ~XSyncBasedPoller() override;
32 
33  bool isAvailable() override;
34  bool setUpPoller() override;
35  void unloadPoller() override;
36 
37  bool xcbEvent(xcb_generic_event_t *event);
38 
39 public Q_SLOTS:
40  void addTimeout(int nextTimeout) override;
41  void removeTimeout(int nextTimeout) override;
42  QList<int> timeouts() const override;
43  int forcePollRequest() override;
44  void catchIdleEvent() override;
45  void stopCatchingIdleEvents() override;
46  void simulateUserActivity() override;
47 
48 private Q_SLOTS:
49  int poll();
50  void reloadAlarms();
51 
52 private:
53  void setAlarm(Display *dpy, XSyncAlarm *alarm, XSyncCounter counter, XSyncTestType test, XSyncValue value);
54 
55 private:
56  Display *m_display;
57  xcb_connection_t *m_xcb_connection;
58 
59  int m_sync_event;
60  XSyncCounter m_idleCounter;
61  QHash<int, XSyncAlarm> m_timeoutAlarm;
62  XSyncAlarm m_resetAlarm;
63  bool m_available;
64 };
65 
66 #endif /* XSYNCBASEDPOLLER_H */
Q_OBJECTQ_OBJECT
Q_INTERFACES(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jan 22 2022 22:45:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.