summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-01-05 14:29:15 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-09 09:45:07 +0100
commitd23322bf1cdb28a5ad3163a789bb94287b0dfc9d (patch)
tree1ba2d20ed532b4f2debc63536d063189a54695b8 /src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
parentc7755d33dbf4b26b208487d4336fca7734bbedcf (diff)
Change QCocoaEventDispatcher timer handling to use QTimerInfoList
This gives us support for the various Qt::TimerTypes. We only use one CFRunLoopTimer to drive all of the Qt timers. We update the time-to-fire for this timer as we add/remove/fire Qt timers. The documentation for the CFRunLoopTimerSetNextFireDate() function says that this is a valid use case, and is more performant than constantly adding and removing CFRunLoopTimers. The documentation recommends using a large interval for this use case (the docs say "several decades", but we use 1 year). Change-Id: Ie7fd7a845f4254699a5b6a5720e7626f2c5e787f Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaeventdispatcher.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
index e6e8180085..823a5626fe 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -92,6 +92,7 @@
#include <QtCore/qstack.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/private/qabstracteventdispatcher_p.h>
+#include <QtCore/private/qtimerinfo_unix_p.h>
#include <CoreFoundation/CoreFoundation.h>
@@ -132,21 +133,6 @@ public:
void flush();
};
-struct MacTimerInfo {
- QCocoaEventDispatcherPrivate *d_ptr;
- int id;
- int interval;
- Qt::TimerType timerType;
- QObject *obj;
- bool pending;
- CFRunLoopTimerRef runLoopTimer;
- bool operator==(const MacTimerInfo &other)
- {
- return (id == other.id);
- }
-};
-typedef QHash<int, MacTimerInfo *> MacTimerHash;
-
struct MacSocketInfo {
MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0) {}
CFSocketRef socket;
@@ -163,7 +149,12 @@ class QCocoaEventDispatcherPrivate : public QAbstractEventDispatcherPrivate
public:
QCocoaEventDispatcherPrivate();
- MacTimerHash macTimerHash;
+ // timer handling
+ QTimerInfoList timerInfoList;
+ CFRunLoopTimerRef runLoopTimerRef;
+ void maybeStartCFRunLoopTimer();
+ void maybeStopCFRunLoopTimer();
+ static void activateTimer(CFRunLoopTimerRef, void *info);
// Set 'blockSendPostedEvents' to true if you _really_ need
// to make sure that qt events are not posted while calling
@@ -196,7 +187,6 @@ public:
static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2);
static void postedEventsSourcePerformCallback(void *info);
- static void activateTimer(CFRunLoopTimerRef, void *info);
static void waitingObserverCallback(CFRunLoopObserverRef observer,
CFRunLoopActivity activity, void *info);
static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);