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.0-only
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 #include "fixx11h.h"
19 
20 class XSyncBasedPoller : public AbstractSystemPoller
21 {
22  Q_OBJECT
23  Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "xcb.json")
24  Q_INTERFACES(AbstractSystemPoller)
25 
26 public:
27  static XSyncBasedPoller *instance();
28 
29  explicit XSyncBasedPoller(QObject *parent = nullptr);
30  ~XSyncBasedPoller() override;
31 
32  bool isAvailable() override;
33  bool setUpPoller() override;
34  void unloadPoller() override;
35 
36  bool xcbEvent(xcb_generic_event_t *event);
37 
38 public Q_SLOTS:
39  void addTimeout(int nextTimeout) override;
40  void removeTimeout(int nextTimeout) override;
41  QList<int> timeouts() const override;
42  int forcePollRequest() override;
43  void catchIdleEvent() override;
44  void stopCatchingIdleEvents() override;
45  void simulateUserActivity() override;
46 
47 private Q_SLOTS:
48  int poll();
49  void reloadAlarms();
50 
51 private:
52  void setAlarm(Display *dpy, XSyncAlarm *alarm, XSyncCounter counter,
53  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 */
67 
Q_OBJECTQ_OBJECT
Q_INTERFACES(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 22:48:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.