summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 23:30:52 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 23:30:52 +0000
commita3c6262246851b00bd5ad315330359de8d341b84 (patch)
tree3e040e74fd4d2fffea3e9d2224615d53bb4d9dbf
parent5dfa20bced5edc7a76e1ac285799fba86acf283c (diff)
downloadchromium_src-a3c6262246851b00bd5ad315330359de8d341b84.zip
chromium_src-a3c6262246851b00bd5ad315330359de8d341b84.tar.gz
chromium_src-a3c6262246851b00bd5ad315330359de8d341b84.tar.bz2
Mac: Fix stuck hover state in bookmark button
Bookmark buttons would get stuck with a hover state if they were obscured while the mouse was inside the button. The problem was that the hover state only tracked the mouse entered and exited events. Unfortunately if the button is obscured because it has been removed from the window then a mouse exited event is not sent. Fix was to also update the hover state in the -[NSCell resetCursorRect:inView:] event. This change also improves the mouse tracking code by checking if the mouse is already in over the button. BUG=27073 TEST=Changed tabs with the mouse over a bookmark button. Verified that the hover effect was no longer there after closing the new tab. Did a similar test by entering full screen. Verified that the hover effect was no longer there. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69068 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/cocoa/gradient_button_cell.mm52
1 files changed, 42 insertions, 10 deletions
diff --git a/chrome/browser/ui/cocoa/gradient_button_cell.mm b/chrome/browser/ui/cocoa/gradient_button_cell.mm
index 205e139..459aa8e 100644
--- a/chrome/browser/ui/cocoa/gradient_button_cell.mm
+++ b/chrome/browser/ui/cocoa/gradient_button_cell.mm
@@ -28,6 +28,7 @@
innerPath:(NSBezierPath**)returnInnerPath
clipPath:(NSBezierPath**)returnClipPath;
+- (void)updateTrackingAreas;
@end
@@ -320,21 +321,16 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
if (showOnly) {
if (trackingArea_.get()) {
[self setShowsBorderOnlyWhileMouseInside:NO];
- [[self controlView] removeTrackingArea:trackingArea_];
}
- trackingArea_.reset([[NSTrackingArea alloc]
- initWithRect:[[self controlView]
- bounds]
- options:(NSTrackingMouseEnteredAndExited |
- NSTrackingActiveInActiveApp)
- owner:self
- userInfo:nil]);
- [[self controlView] addTrackingArea:trackingArea_];
+ [self updateTrackingAreas];
} else {
if (trackingArea_) {
[[self controlView] removeTrackingArea:trackingArea_];
trackingArea_.reset(nil);
- isMouseInside_ = NO;
+ if (isMouseInside_) {
+ isMouseInside_ = NO;
+ [[self controlView] setNeedsDisplay:YES];
+ }
}
}
}
@@ -716,4 +712,40 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
return boundingPath;
}
+- (void)resetCursorRect:(NSRect)cellFrame inView:(NSView*)controlView {
+ [super resetCursorRect:cellFrame inView:controlView];
+ if (trackingArea_)
+ [self updateTrackingAreas];
+}
+
+- (void)updateTrackingAreas {
+ BOOL mouseInView = NO;
+ NSView* controlView = [self controlView];
+ NSWindow* window = [controlView window];
+ NSRect bounds = [controlView bounds];
+ if (window) {
+ NSPoint mousePoint = [window mouseLocationOutsideOfEventStream];
+ mousePoint = [controlView convertPointFromBase:mousePoint];
+ mouseInView = [controlView mouse:mousePoint inRect:bounds];
+ }
+
+ if (trackingArea_.get())
+ [controlView removeTrackingArea:trackingArea_];
+
+ NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
+ NSTrackingActiveInActiveApp;
+ if (mouseInView)
+ options |= NSTrackingAssumeInside;
+
+ trackingArea_.reset([[NSTrackingArea alloc]
+ initWithRect:bounds
+ options:options
+ owner:self
+ userInfo:nil]);
+ if (isMouseInside_ != mouseInView) {
+ isMouseInside_ = mouseInView;
+ [controlView setNeedsDisplay:YES];
+ }
+}
+
@end