MacViews: Implement capture using NSEvent local+global monitors
commit20cd5d3a1e1ff560fff0edfc736bc1ce6cd895a7
authortapted <tapted@chromium.org>
Thu, 18 Dec 2014 00:02:15 +0000 (17 16:02 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 18 Dec 2014 00:02:51 +0000 (18 00:02 +0000)
treeacf1b88e5186c68a06ed3f7582649461e2ec249c
parent4f86aeb731c41877acc3c58b549d29a3df098fab
MacViews: Implement capture using NSEvent local+global monitors

This allows drag&drop to work, and Menus to dismiss themselves properly.

Adds a CocoaMouseCapture to encapsulate the logic to simulate
::SetCapture() from Windows APIs. "Cocoa" because it uses the cocoa APIs
on NSEvent rather than Quartz APIs from CoreGraphics to intercept mouse
events. (Quartz allows events sent to other applications to be
suppressed as well as monitored, but we don't want that).

Allows the WidgetCaptureTests in widget_interactive_test.cc to pass. One
test was failing because the widget could not activate, so the code in
native_widget_mac_interactive_uitest.mm that was setting the activation
policy is moved to views_test_helper_mac.mm.

BUG=403679

Review URL: https://codereview.chromium.org/789763002

Cr-Commit-Position: refs/heads/master@{#308886}
13 files changed:
ui/views/cocoa/bridged_content_view.h
ui/views/cocoa/bridged_content_view.mm
ui/views/cocoa/bridged_native_widget.h
ui/views/cocoa/bridged_native_widget.mm
ui/views/cocoa/cocoa_mouse_capture.h [new file with mode: 0644]
ui/views/cocoa/cocoa_mouse_capture.mm [new file with mode: 0644]
ui/views/cocoa/cocoa_mouse_capture_delegate.h [new file with mode: 0644]
ui/views/cocoa/cocoa_mouse_capture_unittest.mm [new file with mode: 0644]
ui/views/test/views_test_helper_mac.mm
ui/views/views.gyp
ui/views/widget/native_widget_mac.mm
ui/views/widget/native_widget_mac_interactive_uitest.mm
ui/views/widget/widget_interactive_uitest.cc