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

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: fix sorting 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..e3b3d8e0700380423e6c6130153aaaf0dde4fbb3 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -14,6 +14,28 @@
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
+namespace {
+
+// Convert a |point| in |source_window|'s AppKit coordinate system (origin at
+// the bottom left of the window) to |target_window|'s content rect, with the
+// origin at the top left of the content area.
+// If |source_window| is nil, |point| will be treated as screen coordinates.
+gfx::Point MovePointToWindow(const NSPoint& point,
+ NSWindow* source_window,
+ NSWindow* target_window) {
+ NSPoint point_in_screen = source_window
+ ? [source_window convertBaseToScreen:point]
+ : point;
+
+ NSPoint point_in_window = [target_window convertScreenToBase:point_in_screen];
+ NSRect content_rect =
+ [target_window contentRectForFrameRect:[target_window frame]];
+ return gfx::Point(point_in_window.x,
+ NSHeight(content_rect) - point_in_window.y);
+}
+
+}
+
@interface BridgedContentView ()
// Translates the location of |theEvent| to toolkit-views coordinates and passes
@@ -59,6 +81,26 @@
[self removeTrackingArea:trackingArea_.get()];
}
+- (void)processCapturedMouseEvent:(NSEvent*)theEvent {
+ if (!hostedView_)
+ return;
+
+ NSWindow* source = [theEvent window];
+ NSWindow* target = [self window];
+ DCHECK(target);
+
+ // If it's the view's window, process normally.
+ if ([target isEqual:source]) {
+ [self handleMouseEvent:theEvent];
+ return;
+ }
+
+ ui::MouseEvent event(theEvent);
+ event.set_location(
+ MovePointToWindow([theEvent locationInWindow], source, target));
+ 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