| Index: components/mus/ws/event_dispatcher.cc
|
| diff --git a/components/mus/ws/event_dispatcher.cc b/components/mus/ws/event_dispatcher.cc
|
| index 384f9ba81f95b1c2d41d364a79a8a2653dabbe13..e55f6f94ec982e83a4f7cfb042a0cf3da9486275 100644
|
| --- a/components/mus/ws/event_dispatcher.cc
|
| +++ b/components/mus/ws/event_dispatcher.cc
|
| @@ -139,7 +139,10 @@ class EventMatcher {
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate)
|
| - : delegate_(delegate), root_(nullptr) {}
|
| + : delegate_(delegate),
|
| + root_(nullptr),
|
| + mouse_button_down_(false),
|
| + mouse_cursor_source_window_(nullptr) {}
|
|
|
| EventDispatcher::~EventDispatcher() {
|
| std::set<ServerWindow*> pointer_targets;
|
| @@ -261,6 +264,28 @@ void EventDispatcher::DispatchToPointerTarget(const PointerTarget& target,
|
| if (!target.window)
|
| return;
|
|
|
| + if (event->pointer_data->kind == mojom::PointerKind::POINTER_KIND_MOUSE) {
|
| + if (event->action == mojom::EventType::EVENT_TYPE_POINTER_MOVE) {
|
| + // Only change the last targeted window when we are moving without
|
| + // dragging.
|
| + if (!mouse_button_down_)
|
| + mouse_cursor_source_window_ = target.window;
|
| + } else if (event->action == mojom::EventType::EVENT_TYPE_POINTER_UP ||
|
| + event->action == mojom::EventType::EVENT_TYPE_POINTER_CANCEL) {
|
| + mouse_button_down_ = false;
|
| +
|
| + // When we release the mouse button, we want the cursor to be sourced
|
| + // from the window under the mouse pointer, even though we're sending the
|
| + // button up event to the window that had implicit capture.
|
| + gfx::Point location(EventLocationToPoint(*event));
|
| + mouse_cursor_source_window_ =
|
| + FindDeepestVisibleWindowForEvents(root_, surface_id_, &location);
|
| + } else if (event->action == mojom::EventType::EVENT_TYPE_POINTER_DOWN) {
|
| + mouse_button_down_ = true;
|
| + mouse_cursor_source_window_ = target.window;
|
| + }
|
| + }
|
| +
|
| gfx::Point location(EventLocationToPoint(*event));
|
| gfx::Transform transform(GetTransformToWindow(surface_id_, target.window));
|
| transform.TransformPoint(&location);
|
| @@ -311,6 +336,9 @@ void EventDispatcher::OnWindowVisibilityChanged(ServerWindow* window) {
|
|
|
| void EventDispatcher::OnWindowDestroyed(ServerWindow* window) {
|
| CancelPointerEventsToTarget(window);
|
| +
|
| + if (mouse_cursor_source_window_ == window)
|
| + mouse_cursor_source_window_ = nullptr;
|
| }
|
|
|
| } // namespace ws
|
|
|