| Index: ui/aura/window_event_dispatcher.cc
|
| diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc
|
| index 8b2228096f0cfd241ac23db11598536bfde9c161..90519746f9643e3fc1b06a3ffbb7d74168587684 100644
|
| --- a/ui/aura/window_event_dispatcher.cc
|
| +++ b/ui/aura/window_event_dispatcher.cc
|
| @@ -19,6 +19,7 @@
|
| #include "ui/aura/env.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_delegate.h"
|
| +#include "ui/aura/window_event_dispatcher_delegate.h"
|
| #include "ui/aura/window_targeter.h"
|
| #include "ui/aura/window_tracker.h"
|
| #include "ui/aura/window_tree_host.h"
|
| @@ -48,19 +49,6 @@ Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
|
| return consumer ? static_cast<Window*>(consumer) : NULL;
|
| }
|
|
|
| -void SetLastMouseLocation(const Window* root_window,
|
| - const gfx::Point& location_in_root) {
|
| - client::ScreenPositionClient* client =
|
| - client::GetScreenPositionClient(root_window);
|
| - if (client) {
|
| - gfx::Point location_in_screen = location_in_root;
|
| - client->ConvertPointToScreen(root_window, &location_in_screen);
|
| - Env::GetInstance()->set_last_mouse_location(location_in_screen);
|
| - } else {
|
| - Env::GetInstance()->set_last_mouse_location(location_in_root);
|
| - }
|
| -}
|
| -
|
| bool IsEventCandidateForHold(const ui::Event& event) {
|
| if (event.type() == ui::ET_TOUCH_MOVED)
|
| return true;
|
| @@ -88,6 +76,7 @@ WindowEventDispatcher::WindowEventDispatcher(WindowTreeHost* host)
|
| dispatching_held_event_(nullptr),
|
| observer_manager_(this),
|
| transform_events_(true),
|
| + delegate_(new WindowEventDispatcherDelegate),
|
| repost_event_factory_(this),
|
| held_event_factory_(this) {
|
| ui::GestureRecognizer::Get()->AddGestureEventHelper(this);
|
| @@ -204,12 +193,7 @@ void WindowEventDispatcher::ReleasePointerMoves() {
|
| }
|
|
|
| gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const {
|
| - gfx::Point location = Env::GetInstance()->last_mouse_location();
|
| - client::ScreenPositionClient* client =
|
| - client::GetScreenPositionClient(window());
|
| - if (client)
|
| - client->ConvertPointFromScreen(window(), &location);
|
| - return location;
|
| + return delegate_->GetLastMouseLocationInRoot(window());
|
| }
|
|
|
| void WindowEventDispatcher::OnHostLostMouseGrab() {
|
| @@ -219,7 +203,7 @@ void WindowEventDispatcher::OnHostLostMouseGrab() {
|
|
|
| void WindowEventDispatcher::OnCursorMovedToRootLocation(
|
| const gfx::Point& root_location) {
|
| - SetLastMouseLocation(window(), root_location);
|
| + delegate_->SetLastMouseLocation(window(), root_location);
|
|
|
| // Synthesize a mouse move in case the cursor's location in root coordinates
|
| // changed but its position in WindowTreeHost coordinates did not.
|
| @@ -268,7 +252,7 @@ ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit(
|
| ui::EventType type) {
|
| if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED &&
|
| !(event.flags() & ui::EF_IS_SYNTHESIZED)) {
|
| - SetLastMouseLocation(window(), event.root_location());
|
| + delegate_->SetLastMouseLocation(window(), event.root_location());
|
| }
|
|
|
| if (!mouse_moved_handler_ || !mouse_moved_handler_->delegate() ||
|
| @@ -387,7 +371,7 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
|
| if (new_capture) {
|
| // Make all subsequent mouse events go to the capture window. We shouldn't
|
| // need to send an event here as OnCaptureLost() should take care of that.
|
| - if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown())
|
| + if (mouse_moved_handler_ || delegate_->IsMouseButtonDown())
|
| mouse_moved_handler_ = new_capture;
|
| } else {
|
| // Make sure mouse_moved_handler gets updated.
|
| @@ -726,7 +710,7 @@ ui::EventDispatchDetails WindowEventDispatcher::SynthesizeMouseMoveEvent() {
|
| // instead of a MOVED event, but in multi-display/multi-host scenarios, the
|
| // DRAGGED event can be synthesized in the incorrect host. So avoid
|
| // synthesizing any events at all.
|
| - if (Env::GetInstance()->mouse_button_flags())
|
| + if (delegate_->IsMouseButtonDown())
|
| return details;
|
|
|
| gfx::Point root_mouse_location = GetLastMouseLocationInRoot();
|
| @@ -752,7 +736,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchLocatedEvent(
|
| (event->IsMouseEvent() || event->IsScrollEvent()) &&
|
| !(event->flags() & ui::EF_IS_SYNTHESIZED)) {
|
| if (event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)
|
| - SetLastMouseLocation(window(), event->root_location());
|
| + delegate_->SetLastMouseLocation(window(), event->root_location());
|
| synthesize_mouse_move_ = false;
|
| }
|
|
|
| @@ -778,7 +762,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
|
| if (move_hold_count_) {
|
| if (!(event->flags() & ui::EF_IS_SYNTHESIZED) &&
|
| event->type() != ui::ET_MOUSE_CAPTURE_CHANGED) {
|
| - SetLastMouseLocation(window(), event->root_location());
|
| + delegate_->SetLastMouseLocation(window(), event->root_location());
|
| }
|
| held_move_event_.reset(new ui::MouseEvent(*event, target, window()));
|
| event->SetHandled();
|
| @@ -851,17 +835,16 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
|
| // sent to the wrong target.
|
| if (!(event->flags() & ui::EF_IS_NON_CLIENT) && !mouse_pressed_handler_)
|
| mouse_pressed_handler_ = target;
|
| - Env::GetInstance()->set_mouse_button_flags(event->button_flags());
|
| break;
|
| case ui::ET_MOUSE_RELEASED:
|
| mouse_pressed_handler_ = NULL;
|
| - Env::GetInstance()->set_mouse_button_flags(
|
| - event->button_flags() & ~event->changed_button_flags());
|
| break;
|
| default:
|
| break;
|
| }
|
|
|
| + delegate_->PreDispatchMouseEvent(event);
|
| +
|
| return PreDispatchLocatedEvent(target, event);
|
| }
|
|
|
| @@ -871,7 +854,6 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
|
| switch (event->type()) {
|
| case ui::ET_TOUCH_PRESSED:
|
| touch_ids_down_ |= (1 << event->touch_id());
|
| - Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
|
| break;
|
|
|
| // Handle ET_TOUCH_CANCELLED only if it has a native event.
|
| @@ -882,7 +864,6 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
|
| case ui::ET_TOUCH_RELEASED:
|
| touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^
|
| (1 << event->touch_id());
|
| - Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
|
| break;
|
|
|
| case ui::ET_TOUCH_MOVED:
|
| @@ -898,6 +879,8 @@ DispatchDetails WindowEventDispatcher::PreDispatchTouchEvent(
|
| break;
|
| }
|
|
|
| + delegate_->PreDispatchTouchEvent(event, touch_ids_down_);
|
| +
|
| ui::TouchEvent orig_event(*event, target, window());
|
| if (!ui::GestureRecognizer::Get()->ProcessTouchEventPreDispatch(&orig_event,
|
| target)) {
|
|
|