| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
| 15 #include "ui/aura/client/cursor_client.h" | 15 #include "ui/aura/client/cursor_client.h" |
| 16 #include "ui/aura/client/event_client.h" | 16 #include "ui/aura/client/event_client.h" |
| 17 #include "ui/aura/client/focus_client.h" | 17 #include "ui/aura/client/focus_client.h" |
| 18 #include "ui/aura/client/screen_position_client.h" | 18 #include "ui/aura/client/screen_position_client.h" |
| 19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 20 #include "ui/aura/env_input_state_controller.h" | 20 #include "ui/aura/env_input_state_controller.h" |
| 21 #include "ui/aura/mus/mus_mouse_location_updater.h" |
| 21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_delegate.h" | 23 #include "ui/aura/window_delegate.h" |
| 23 #include "ui/aura/window_targeter.h" | 24 #include "ui/aura/window_targeter.h" |
| 24 #include "ui/aura/window_tracker.h" | 25 #include "ui/aura/window_tracker.h" |
| 25 #include "ui/aura/window_tree_host.h" | 26 #include "ui/aura/window_tree_host.h" |
| 26 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
| 27 #include "ui/compositor/dip_util.h" | 28 #include "ui/compositor/dip_util.h" |
| 28 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
| 29 #include "ui/events/event_utils.h" | 30 #include "ui/events/event_utils.h" |
| 30 #include "ui/events/gestures/gesture_recognizer.h" | 31 #include "ui/events/gestures/gesture_recognizer.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 old_dispatch_target_(NULL), | 73 old_dispatch_target_(NULL), |
| 73 synthesize_mouse_move_(false), | 74 synthesize_mouse_move_(false), |
| 74 move_hold_count_(0), | 75 move_hold_count_(0), |
| 75 dispatching_held_event_(nullptr), | 76 dispatching_held_event_(nullptr), |
| 76 observer_manager_(this), | 77 observer_manager_(this), |
| 77 env_controller_(new EnvInputStateController), | 78 env_controller_(new EnvInputStateController), |
| 78 repost_event_factory_(this), | 79 repost_event_factory_(this), |
| 79 held_event_factory_(this) { | 80 held_event_factory_(this) { |
| 80 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); | 81 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); |
| 81 Env::GetInstance()->AddObserver(this); | 82 Env::GetInstance()->AddObserver(this); |
| 83 if (Env::GetInstance()->mode() == Env::Mode::MUS) |
| 84 mus_mouse_location_updater_ = base::MakeUnique<MusMouseLocationUpdater>(); |
| 82 } | 85 } |
| 83 | 86 |
| 84 WindowEventDispatcher::~WindowEventDispatcher() { | 87 WindowEventDispatcher::~WindowEventDispatcher() { |
| 85 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); | 88 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); |
| 86 Env::GetInstance()->RemoveObserver(this); | 89 Env::GetInstance()->RemoveObserver(this); |
| 87 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this); | 90 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this); |
| 88 } | 91 } |
| 89 | 92 |
| 90 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) { | 93 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) { |
| 91 DCHECK(event->type() == ui::ET_MOUSE_PRESSED || | 94 DCHECK(event->type() == ui::ET_MOUSE_PRESSED || |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 ui::EventTarget* WindowEventDispatcher::GetRootTarget() { | 419 ui::EventTarget* WindowEventDispatcher::GetRootTarget() { |
| 417 return window(); | 420 return window(); |
| 418 } | 421 } |
| 419 | 422 |
| 420 void WindowEventDispatcher::OnEventProcessingStarted(ui::Event* event) { | 423 void WindowEventDispatcher::OnEventProcessingStarted(ui::Event* event) { |
| 421 // The held events are already in |window()|'s coordinate system. So it is | 424 // The held events are already in |window()|'s coordinate system. So it is |
| 422 // not necessary to apply the transform to convert from the host's | 425 // not necessary to apply the transform to convert from the host's |
| 423 // coordinate system to |window()|'s coordinate system. | 426 // coordinate system to |window()|'s coordinate system. |
| 424 if (event->IsLocatedEvent() && !is_dispatched_held_event(*event)) | 427 if (event->IsLocatedEvent() && !is_dispatched_held_event(*event)) |
| 425 TransformEventForDeviceScaleFactor(static_cast<ui::LocatedEvent*>(event)); | 428 TransformEventForDeviceScaleFactor(static_cast<ui::LocatedEvent*>(event)); |
| 429 |
| 430 if (mus_mouse_location_updater_) |
| 431 mus_mouse_location_updater_->OnEventProcessingStarted(*event); |
| 432 } |
| 433 |
| 434 void WindowEventDispatcher::OnEventProcessingFinished(ui::Event* event) { |
| 435 if (mus_mouse_location_updater_) |
| 436 mus_mouse_location_updater_->OnEventProcessingFinished(); |
| 426 } | 437 } |
| 427 | 438 |
| 428 //////////////////////////////////////////////////////////////////////////////// | 439 //////////////////////////////////////////////////////////////////////////////// |
| 429 // WindowEventDispatcher, ui::EventDispatcherDelegate implementation: | 440 // WindowEventDispatcher, ui::EventDispatcherDelegate implementation: |
| 430 | 441 |
| 431 bool WindowEventDispatcher::CanDispatchToTarget(ui::EventTarget* target) { | 442 bool WindowEventDispatcher::CanDispatchToTarget(ui::EventTarget* target) { |
| 432 return event_dispatch_target_ == target; | 443 return event_dispatch_target_ == target; |
| 433 } | 444 } |
| 434 | 445 |
| 435 ui::EventDispatchDetails WindowEventDispatcher::PreDispatchEvent( | 446 ui::EventDispatchDetails WindowEventDispatcher::PreDispatchEvent( |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } | 870 } |
| 860 | 871 |
| 861 // This flag is set depending on the gestures recognized in the call above, | 872 // This flag is set depending on the gestures recognized in the call above, |
| 862 // and needs to propagate with the forwarded event. | 873 // and needs to propagate with the forwarded event. |
| 863 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); | 874 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); |
| 864 | 875 |
| 865 return PreDispatchLocatedEvent(target, event); | 876 return PreDispatchLocatedEvent(target, event); |
| 866 } | 877 } |
| 867 | 878 |
| 868 } // namespace aura | 879 } // namespace aura |
| OLD | NEW |