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

Unified Diff: ui/views/cocoa/bridged_native_widget.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_native_widget.h ('k') | ui/views/cocoa/cocoa_mouse_capture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
index 1b8b098fbeb05a4bc5bd072dc665266e01a9ca20..591f4cba9f2232b5969c2d79e46de9a81c37cf90 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -15,6 +15,7 @@
#include "ui/gfx/geometry/dip_util.h"
#import "ui/gfx/mac/coordinate_conversion.h"
#include "ui/gfx/screen.h"
+#import "ui/views/cocoa/cocoa_mouse_capture.h"
#import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/views_nswindow_delegate.h"
#include "ui/views/widget/native_widget_mac.h"
@@ -191,6 +192,22 @@ void BridgedNativeWidget::SetVisibilityState(WindowVisibilityState new_state) {
NotifyVisibilityChangeDown();
}
+void BridgedNativeWidget::AcquireCapture() {
+ DCHECK(!HasCapture());
+ if (!window_visible_)
+ return; // Capture on hidden windows is disallowed.
+
+ mouse_capture_.reset(new CocoaMouseCapture(this));
+}
+
+void BridgedNativeWidget::ReleaseCapture() {
+ mouse_capture_.reset();
+}
+
+bool BridgedNativeWidget::HasCapture() {
+ return mouse_capture_ && mouse_capture_->IsActive();
+}
+
void BridgedNativeWidget::OnWindowWillClose() {
if (parent_)
parent_->RemoveChildWindow(this);
@@ -294,6 +311,10 @@ void BridgedNativeWidget::OnVisibilityChangedTo(bool new_visibility) {
if (window_visible_)
wants_to_be_visible_ = true;
+ // Capture on hidden windows is not permitted.
+ if (!window_visible_)
+ mouse_capture_.reset();
+
// TODO(tapted): Investigate whether we want this for Mac. This is what Aura
// does, and it is what tests expect. However, because layer drawing is
// asynchronous (and things like deminiaturize in AppKit are not), it can
@@ -383,6 +404,17 @@ void BridgedNativeWidget::DispatchKeyEventPostIME(const ui::KeyEvent& key) {
}
////////////////////////////////////////////////////////////////////////////////
+// BridgedNativeWidget, CocoaMouseCaptureDelegate:
+
+void BridgedNativeWidget::PostCapturedEvent(NSEvent* event) {
+ [bridged_view_ processCapturedMouseEvent:event];
+}
+
+void BridgedNativeWidget::OnMouseCaptureLost() {
+ native_widget_mac_->GetWidget()->OnMouseCaptureLost();
+}
+
+////////////////////////////////////////////////////////////////////////////////
// BridgedNativeWidget, FocusChangeListener:
void BridgedNativeWidget::OnWillChangeFocus(View* focused_before,
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/cocoa_mouse_capture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698