summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsview.mm
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-01-24 16:37:58 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-24 18:34:11 +0100
commitd0c360fd88760372f4f67219440ee17a11023d98 (patch)
treee08ad106519090524a526a43d82500c0a0775171 /src/plugins/platforms/cocoa/qnsview.mm
parent9c6a91d07bae5517a9909ef5b6f4acb1e99ec948 (diff)
parent627d9cbd3c45834fe7aa1f2ee37fdfca07a03976 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-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 14c24beabf..61ddfe9498 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -490,6 +490,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];