Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2776)

Unified Diff: chrome/browser/cocoa/base_view.mm

Issue 1774014: Enable mouse enter/exit events for the content area on Mac (Closed)
Patch Set: Fixes drag-scroll handling Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/base_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/base_view.mm
diff --git a/chrome/browser/cocoa/base_view.mm b/chrome/browser/cocoa/base_view.mm
index e5ed3a285f513f7179ca8b2fa4cc705b5abb5480..cee89511abfc416f7f6b714a93d8021ae6a0769a 100644
--- a/chrome/browser/cocoa/base_view.mm
+++ b/chrome/browser/cocoa/base_view.mm
@@ -12,6 +12,7 @@
trackingArea_ =
[[NSTrackingArea alloc] initWithRect:frame
options:NSTrackingMouseMoved |
+ NSTrackingMouseEnteredAndExited |
NSTrackingActiveInActiveApp |
NSTrackingInVisibleRect
owner:self
@@ -37,6 +38,7 @@
}
- (void)mouseDown:(NSEvent *)theEvent {
+ dragging_ = YES;
[self mouseEvent:theEvent];
}
@@ -50,6 +52,22 @@
- (void)mouseUp:(NSEvent *)theEvent {
[self mouseEvent:theEvent];
+
+ dragging_ = NO;
+ if (pendingExitEvent_.get()) {
+ NSEvent* exitEvent =
+ [NSEvent enterExitEventWithType:NSMouseExited
+ location:[theEvent locationInWindow]
+ modifierFlags:[theEvent modifierFlags]
+ timestamp:[theEvent timestamp]
+ windowNumber:[theEvent windowNumber]
+ context:[theEvent context]
+ eventNumber:[pendingExitEvent_.get() eventNumber]
+ trackingNumber:[pendingExitEvent_.get() trackingNumber]
+ userData:[pendingExitEvent_.get() userData]];
+ [self mouseEvent:exitEvent];
+ pendingExitEvent_.reset();
+ }
}
- (void)rightMouseUp:(NSEvent *)theEvent {
@@ -77,10 +95,23 @@
}
- (void)mouseEntered:(NSEvent *)theEvent {
+ if (pendingExitEvent_.get()) {
+ pendingExitEvent_.reset();
+ return;
+ }
+
[self mouseEvent:theEvent];
}
- (void)mouseExited:(NSEvent *)theEvent {
+ // The tracking area will send an exit event even during a drag, which isn't
+ // how the event flow for drags should work. This stores the exit event, and
+ // sends it when the drag completes instead.
+ if (dragging_) {
+ pendingExitEvent_.reset([theEvent retain]);
+ return;
+ }
+
[self mouseEvent:theEvent];
}
« no previous file with comments | « chrome/browser/cocoa/base_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698