summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-02-01 14:02:02 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-02 09:27:25 +0100
commitb2b3abe0ebc0ca147e1a29d06d1872bc09bf16cc (patch)
tree83c0b86549cd05525a93dc9542e204622f2e8d40 /src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
parent8fad23f3261bdcf9bd0e11980ebfc3b00c2469c6 (diff)
Remove duplicated function from QCocoaEventDispatcher
The qt_mac_waitForMoreModalSessionEvents() is identical to qt_mac_waitForMoreEvents(), except that it passes a different inMode parameter to [NSApp nextEventMatchingMask]. Change the latter function to take the mode as a parameter itself, defaulting to the default mode. Change the dequeue parameter to [NSApp nextEventMatchingMask] from YES to NO. Having the function dequeue the event, and then immediately reposting the event is not necessary. Change-Id: Iba45d41ad3ff4d5721d1068e6d5c78585cb15810 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 8e7b14069f..dbb8625aeb 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -488,32 +488,16 @@ static bool IsMouseOrKeyEvent( NSEvent* event )
return result;
}
-static inline void qt_mac_waitForMoreEvents()
+static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRunLoopMode)
{
// If no event exist in the cocoa event que, wait
// (and free up cpu time) until at least one event occur.
// This implementation is a bit on the edge, but seems to
// work fine:
- NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantFuture]
- inMode:NSDefaultRunLoopMode
- dequeue:YES];
- if (event)
- [NSApp postEvent:event atStart:YES];
-}
-
-static inline void qt_mac_waitForMoreModalSessionEvents()
-{
- // If no event exist in the cocoa event que, wait
- // (and free up cpu time) until at least one event occur.
- // This implementation is a bit on the edge, but seems to
- // work fine:
- NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantFuture]
- inMode:NSModalPanelRunLoopMode
- dequeue:YES];
- if (event)
- [NSApp postEvent:event atStart:YES];
+ [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantFuture]
+ inMode:runLoopMode
+ dequeue:NO];
}
bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
@@ -568,7 +552,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (NSModalSession session = d->currentModalSession()) {
QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
- qt_mac_waitForMoreModalSessionEvents();
+ qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
if (!d->interrupt && session == d->currentModalSessionCached) {
// Someone called [NSApp stopModal:] from outside the event
@@ -592,7 +576,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
// Since we can dispatch all kinds of events, we choose
// to use cocoa's native way of running modal sessions:
if (flags & QEventLoop::WaitForMoreEvents)
- qt_mac_waitForMoreModalSessionEvents();
+ qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
NSInteger status = [NSApp runModalSession:session];
if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
// INVARIANT: Someone called [NSApp stopModal:] from outside the event