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

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

Issue 2096993002: MacViews: Fix failing mouse capture unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mouse_capture_lifetime
Patch Set: Enable tests. Created 4 years, 6 months 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/cocoa_mouse_capture.h ('k') | ui/views/cocoa/cocoa_mouse_capture_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « ui/views/cocoa/cocoa_mouse_capture.h ('k') | ui/views/cocoa/cocoa_mouse_capture_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698