Index: ui/views/cocoa/bridged_content_view.mm |
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
index 88a5b84de02afe7f709d6c19cc343db02f248143..5b71cd35e406451159674b270ec70c0fdef52505 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -32,6 +32,8 @@ using views::MenuController; |
namespace { |
+bool g_ignore_mouse_events = false; |
+ |
// Returns true if all four corners of |rect| are contained inside |path|. |
bool IsRectInsidePath(NSRect rect, NSBezierPath* path) { |
return [path containsPoint:rect.origin] && |
@@ -200,6 +202,7 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
@synthesize hostedView = hostedView_; |
@synthesize textInputClient = textInputClient_; |
@synthesize drawMenuBackgroundForBlur = drawMenuBackgroundForBlur_; |
+@synthesize ignoreMouseEvents = ignoreMouseEvents_; |
@synthesize mouseDownCanMoveWindow = mouseDownCanMoveWindow_; |
- (id)initWithView:(views::View*)viewToHost { |
@@ -225,6 +228,11 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
return self; |
} |
+- (void)setIgnoreMouseEvents:(BOOL)flag { |
+ ignoreMouseEvents_ = flag; |
+ g_ignore_mouse_events = flag; |
+} |
+ |
- (void)clearView { |
textInputClient_ = nullptr; |
hostedView_ = nullptr; |
@@ -233,6 +241,10 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
} |
- (void)processCapturedMouseEvent:(NSEvent*)theEvent { |
+ if (CGEventGetIntegerValueField([theEvent CGEvent], kCGEventSourceUserData)) { |
+ return; |
+ } |
+ |
if (!hostedView_) |
return; |
@@ -391,7 +403,11 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
// Translates the location of |theEvent| to toolkit-views coordinates and passes |
// the event to NativeWidgetMac for handling. |
- (void)mouseEvent:(NSEvent*)theEvent { |
- if (!hostedView_) |
+ if (CGEventGetIntegerValueField([theEvent CGEvent], kCGEventSourceUserData)) { |
+ return; |
+ } |
+ |
+ if (!hostedView_ || g_ignore_mouse_events) |
return; |
ui::MouseEvent event(theEvent); |
@@ -888,6 +904,13 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client, |
return @[]; |
} |
+// FIXME(mblsha): We don't want to enable acceptsFirstMouse: for everything. In |
+// non-MacViews browser it's enabled only for RenderWidgetHostViewCocoa, |
+// TabView, TabStripView, PanelTitlebarViewCocoa and OneClickHyperlinkTextView. |
+- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent { |
+ return YES; |
+} |
+ |
// NSUserInterfaceValidations protocol implementation. |
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |