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

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 789763002: MacViews: Implement capture using NSEvent local+global monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140812-MacViews-LAYERS2-PRESQUASH
Patch Set: NULL -> nullptr Created 6 years 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 | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/cocoa/bridged_native_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 df3db44b3870fbe7cf988ca045b78d0e43178369..92f3be7863d6d7719d00949044393055c635a580 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -9,6 +9,7 @@
#include "base/strings/sys_string_conversions.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/gfx/canvas_paint_mac.h"
+#import "ui/gfx/mac/coordinate_conversion.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/view.h"
@@ -59,6 +60,33 @@
[self removeTrackingArea:trackingArea_.get()];
}
+- (void)processCapturedMouseEvent:(NSEvent*)theEvent {
+ if (!hostedView_)
+ return;
+
+ NSWindow* source = [theEvent window];
+ NSWindow* target = [self window];
+ DCHECK(target);
+
+ // If there's no window, or it's the view's window, process normally.
+ if (!source || [target isEqual:source]) {
+ [self handleMouseEvent:theEvent];
+ return;
+ }
+
+ // Otherwise, the coordinates will be based in another window's. Modifying
+ // NSEvents is hard, so convert by translating by the relative locations of
+ // *top* left of the *content* area of each window, in screen coordinates.
+ NSRect sourceRect = [source contentRectForFrameRect:[source frame]];
+ NSRect targetRect = [target contentRectForFrameRect:[target frame]];
+ gfx::Vector2d offset(NSMinX(sourceRect) - NSMinX(targetRect),
+ NSMaxY(targetRect) - NSMaxY(sourceRect));
+
+ ui::MouseEvent event(theEvent);
+ event.set_location(event.location() + offset);
+ hostedView_->GetWidget()->OnMouseEvent(&event);
+}
+
// BridgedContentView private implementation.
- (void)handleMouseEvent:(NSEvent*)theEvent {
« no previous file with comments | « ui/views/cocoa/bridged_content_view.h ('k') | ui/views/cocoa/bridged_native_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698