KUtils
xsyncbasedpoller.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2009 Dario Freddi <drf at kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef XSYNCBASEDPOLLER_H 00020 #define XSYNCBASEDPOLLER_H 00021 00022 #include "abstractsystempoller.h" 00023 00024 #include <kdebug.h> 00025 #include <kapplication.h> 00026 00027 #include <config-kidletime.h> 00028 00029 #include <X11/Xlib.h> 00030 #include <X11/extensions/sync.h> 00031 00032 class XSyncBasedPoller : public AbstractSystemPoller 00033 { 00034 Q_OBJECT 00035 00036 public: 00037 static XSyncBasedPoller *instance(); 00038 00039 virtual ~XSyncBasedPoller(); 00040 00041 bool isAvailable(); 00042 bool setUpPoller(); 00043 void unloadPoller(); 00044 00045 protected: 00046 bool x11Event(XEvent *event); 00047 XSyncBasedPoller(QWidget *parent = 0); 00048 00049 public slots: 00050 void addTimeout(int nextTimeout); 00051 void removeTimeout(int nextTimeout); 00052 QList<int> timeouts() const; 00053 int forcePollRequest(); 00054 void catchIdleEvent(); 00055 void stopCatchingIdleEvents(); 00056 void simulateUserActivity(); 00057 00058 private slots: 00059 int poll(); 00060 void reloadAlarms(); 00061 00062 private: 00063 void setAlarm(Display *dpy, XSyncAlarm *alarm, XSyncCounter counter, 00064 XSyncTestType test, XSyncValue value); 00065 00066 private: 00067 Display * m_display; 00068 int m_sync_event, m_sync_error; 00069 XSyncCounter m_idleCounter; 00070 QHash<int, XSyncAlarm> m_timeoutAlarm; 00071 XSyncAlarm m_resetAlarm; 00072 bool m_available; 00073 }; 00074 00075 #endif /* XSYNCBASEDPOLLER_H */ 00076 00077
KDE 4.6 API Reference