Chromium Code Reviews| Index: services/ui/ws/event_dispatcher.cc |
| diff --git a/services/ui/ws/event_dispatcher.cc b/services/ui/ws/event_dispatcher.cc |
| index 83e8b37f26e8aafdacbec4f0fc45566195c18068..244799e69872dc39c9d88eafe07922ca93e45e00 100644 |
| --- a/services/ui/ws/event_dispatcher.cc |
| +++ b/services/ui/ws/event_dispatcher.cc |
| @@ -46,6 +46,7 @@ EventDispatcher::EventDispatcher(EventDispatcherDelegate* delegate) |
| capture_window_(nullptr), |
| capture_window_client_id_(kInvalidClientId), |
| modal_window_controller_(this), |
| + event_targeter_(new EventTargeter(delegate_, &modal_window_controller_)), |
|
sky
2017/05/26 19:53:43
MakeUnique
riajiang
2017/05/26 21:06:49
Done.
|
| mouse_button_down_(false), |
| mouse_cursor_source_window_(nullptr), |
| mouse_cursor_in_non_client_area_(false) {} |
| @@ -220,7 +221,8 @@ const ServerWindow* EventDispatcher::GetWindowForMouseCursor() const { |
| void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { |
| if (mouse_cursor_source_window_) { |
| DeepestWindow deepest_window = |
| - FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_); |
| + event_targeter_->FindDeepestVisibleWindowForEvents( |
| + mouse_pointer_last_location_); |
| if (deepest_window.window == mouse_cursor_source_window_) { |
| mouse_cursor_in_non_client_area_ = mouse_cursor_source_window_ |
| ? deepest_window.in_non_client_area |
| @@ -232,7 +234,8 @@ void EventDispatcher::UpdateNonClientAreaForCurrentWindow() { |
| void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { |
| if (!mouse_button_down_) { |
| DeepestWindow deepest_window = |
| - FindDeepestVisibleWindowForEvents(mouse_pointer_last_location_); |
| + event_targeter_->FindDeepestVisibleWindowForEvents( |
| + mouse_pointer_last_location_); |
| SetMouseCursorSourceWindow(deepest_window.window); |
| if (mouse_cursor_source_window_) { |
| mouse_cursor_in_non_client_area_ = deepest_window.in_non_client_area; |
| @@ -370,7 +373,7 @@ void EventDispatcher::ProcessPointerEvent(const ui::PointerEvent& event) { |
| } |
| if (drag_controller_) { |
| - const PointerTarget target = PointerTargetForEvent(event); |
| + const PointerTarget target = event_targeter_->PointerTargetForEvent(event); |
| if (drag_controller_->DispatchPointerEvent(event, target.window)) |
| return; |
| } |
| @@ -446,11 +449,13 @@ void EventDispatcher::StopTrackingPointer(int32_t pointer_id) { |
| void EventDispatcher::UpdateTargetForPointer(int32_t pointer_id, |
| const ui::LocatedEvent& event) { |
| if (!IsTrackingPointer(pointer_id)) { |
| - StartTrackingPointer(pointer_id, PointerTargetForEvent(event)); |
| + StartTrackingPointer(pointer_id, |
| + event_targeter_->PointerTargetForEvent(event)); |
| return; |
| } |
| - const PointerTarget pointer_target = PointerTargetForEvent(event); |
| + const PointerTarget pointer_target = |
| + event_targeter_->PointerTargetForEvent(event); |
| if (pointer_target.window == pointer_targets_[pointer_id].window && |
| pointer_target.in_nonclient_area == |
| pointer_targets_[pointer_id].in_nonclient_area) { |
| @@ -478,21 +483,6 @@ void EventDispatcher::UpdateTargetForPointer(int32_t pointer_id, |
| StartTrackingPointer(pointer_id, pointer_target); |
| } |
| -EventDispatcher::PointerTarget EventDispatcher::PointerTargetForEvent( |
| - const ui::LocatedEvent& event) { |
| - PointerTarget pointer_target; |
| - DeepestWindow deepest_window = |
| - FindDeepestVisibleWindowForEvents(event.root_location()); |
| - pointer_target.window = |
| - modal_window_controller_.GetTargetForWindow(deepest_window.window); |
| - pointer_target.is_mouse_event = event.IsMousePointerEvent(); |
| - pointer_target.in_nonclient_area = |
| - deepest_window.window != pointer_target.window || |
| - !pointer_target.window || deepest_window.in_non_client_area; |
| - pointer_target.is_pointer_down = event.type() == ui::ET_POINTER_DOWN; |
| - return pointer_target; |
| -} |
| - |
| bool EventDispatcher::AreAnyPointersDown() const { |
| for (const auto& pair : pointer_targets_) { |
| if (pair.second.is_pointer_down) |
| @@ -580,16 +570,6 @@ Accelerator* EventDispatcher::FindAccelerator( |
| return nullptr; |
| } |
| -DeepestWindow EventDispatcher::FindDeepestVisibleWindowForEvents( |
| - const gfx::Point& location) { |
| - gfx::Point relative_location(location); |
| - // For the case of no root. |
| - ServerWindow* root = delegate_->GetRootWindowContaining(&relative_location); |
| - return root ? ui::ws::FindDeepestVisibleWindowForEvents(root, |
| - relative_location) |
| - : DeepestWindow(); |
| -} |
| - |
| void EventDispatcher::CancelImplicitCaptureExcept(ServerWindow* window, |
| ClientSpecificId client_id) { |
| for (const auto& pair : pointer_targets_) { |