Index: ui/views/cocoa/cocoa_mouse_capture.mm |
diff --git a/ui/views/cocoa/cocoa_mouse_capture.mm b/ui/views/cocoa/cocoa_mouse_capture.mm |
index 17d34ec5bfd30fc549d42f8e2fee77fc7d25702b..74c6a7c69eafc3fda494a9bbb12e7292c9e46d43 100644 |
--- a/ui/views/cocoa/cocoa_mouse_capture.mm |
+++ b/ui/views/cocoa/cocoa_mouse_capture.mm |
@@ -20,9 +20,17 @@ class CocoaMouseCapture::ActiveEventTap { |
public: |
explicit ActiveEventTap(CocoaMouseCapture* owner); |
~ActiveEventTap(); |
+ |
+ // Returns the NSWindow with capture or nil if no window has capture |
+ // currently. |
+ static NSWindow* GetGlobalCaptureWindow(); |
+ |
void Init(); |
private: |
+ // Returns the associated NSWindow with capture. |
+ NSWindow* GetCaptureWindow() const; |
+ |
// The currently active event tap, or null if there is none. |
static ActiveEventTap* g_active_event_tap; |
@@ -52,6 +60,11 @@ CocoaMouseCapture::ActiveEventTap::~ActiveEventTap() { |
owner_->delegate_->OnMouseCaptureLost(); |
} |
+// static |
+NSWindow* CocoaMouseCapture::ActiveEventTap::GetGlobalCaptureWindow() { |
+ return g_active_event_tap ? g_active_event_tap->GetCaptureWindow() : nil; |
+} |
+ |
void CocoaMouseCapture::ActiveEventTap::Init() { |
NSEventMask event_mask = |
NSLeftMouseDownMask | NSLeftMouseUpMask | NSRightMouseDownMask | |
@@ -71,6 +84,10 @@ void CocoaMouseCapture::ActiveEventTap::Init() { |
}]; |
} |
+NSWindow* CocoaMouseCapture::ActiveEventTap::GetCaptureWindow() const { |
+ return owner_->delegate_->GetWindow(); |
+} |
+ |
CocoaMouseCapture::CocoaMouseCapture(CocoaMouseCaptureDelegate* delegate) |
: delegate_(delegate), active_handle_(new ActiveEventTap(this)) { |
active_handle_->Init(); |
@@ -79,6 +96,11 @@ CocoaMouseCapture::CocoaMouseCapture(CocoaMouseCaptureDelegate* delegate) |
CocoaMouseCapture::~CocoaMouseCapture() { |
} |
+// static |
+NSWindow* CocoaMouseCapture::GetGlobalCaptureWindow() { |
+ return ActiveEventTap::GetGlobalCaptureWindow(); |
+} |
+ |
void CocoaMouseCapture::OnOtherClientGotCapture() { |
DCHECK(active_handle_); |
active_handle_.reset(); |