summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-24 11:33:17 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-24 11:33:58 +0100
commit1b5f9bec03901519db3694d1b51fa7989ade1f25 (patch)
tree2b7d539e8f631112e77ae5e2e5867f8ada1febb1 /src/plugins/platforms/cocoa
parentbfd73eaba3000861037d03787f87d1f4dafefea8 (diff)
parentd4f4ee4e033a62858aaf4f29970bc404d9b4c009 (diff)
Merge remote-tracking branch 'origin/release' into stable
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 715b0c367f..a0e76cb452 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -473,6 +473,39 @@ static QTouchDevice *touchDevice = 0;
[self handleMouseEvent:theEvent];
}
+- (void)updateTrackingAreas
+{
+ [super updateTrackingAreas];
+
+ // [NSView addTrackingArea] is slow, so bail out early if we can:
+ if (NSIsEmptyRect([self visibleRect]))
+ return;
+
+ QCocoaAutoReleasePool pool;
+ if (NSArray *trackingArray = [self trackingAreas]) {
+ NSUInteger size = [trackingArray count];
+ for (NSUInteger i = 0; i < size; ++i) {
+ NSTrackingArea *t = [trackingArray objectAtIndex:i];
+ [self removeTrackingArea:t];
+ }
+ }
+
+ // Ideally, we shouldn't have NSTrackingMouseMoved events included below, it should
+ // only be turned on if mouseTracking, hover is on or a tool tip is set.
+ // Unfortunately, Qt will send "tooltip" events on mouse moves, so we need to
+ // turn it on in ALL case. That means EVERY QCocoaView gets to pay the cost of
+ // mouse moves delivered to it (Apple recommends keeping it OFF because there
+ // is a performance hit). So it goes.
+ NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp
+ | NSTrackingInVisibleRect | NSTrackingMouseMoved;
+ NSTrackingArea *ta = [[[NSTrackingArea alloc] initWithRect:[self frame]
+ options:trackingOptions
+ owner:self
+ userInfo:nil]
+ autorelease];
+ [self addTrackingArea:ta];
+}
+
- (void)mouseMoved:(NSEvent *)theEvent
{
[self handleMouseEvent:theEvent];