Chromium Code Reviews| Index: ash/autoclick/autoclick_controller.cc |
| diff --git a/ash/autoclick/autoclick_controller.cc b/ash/autoclick/autoclick_controller.cc |
| index 47846dcaa5aeea29c7d3746c709a2f1f3662f220..45b89073aaa11489e3650eeba1feba56e70f1175 100644 |
| --- a/ash/autoclick/autoclick_controller.cc |
| +++ b/ash/autoclick/autoclick_controller.cc |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "ash/autoclick/autoclick_controller.h" |
| +#include "ash/autoclick/autoclick_ring_handler.h" |
| #include "ash/shell.h" |
| #include "ash/wm/aura/wm_window_aura.h" |
| @@ -63,6 +64,9 @@ class AutoclickControllerImpl : public AutoclickController, |
| void OnGestureEvent(ui::GestureEvent* event) override; |
| void OnScrollEvent(ui::ScrollEvent* event) override; |
| + void StartRingDisplay(ui::LocatedEvent* event); |
| + void StopRingDisplay(ui::LocatedEvent* event); |
| + |
| void InitClickTimer(); |
| void DoAutoclick(); |
| @@ -71,6 +75,7 @@ class AutoclickControllerImpl : public AutoclickController, |
| int delay_ms_; |
| int mouse_event_flags_; |
| std::unique_ptr<base::Timer> autoclick_timer_; |
| + std::unique_ptr<LongPressAutoclickRingHandler> autoclick_ring_display_; |
| // The position in screen coordinates used to determine |
| // the distance the mouse has moved. |
| gfx::Point anchor_location_; |
| @@ -85,6 +90,7 @@ AutoclickControllerImpl::AutoclickControllerImpl() |
| mouse_event_flags_(ui::EF_NONE), |
| anchor_location_(-kMovementThreshold, -kMovementThreshold) { |
| InitClickTimer(); |
| + autoclick_ring_display_.reset(new LongPressAutoclickRingHandler); |
|
jdufault
2016/05/31 19:06:15
Use trailing parens with constructors: new LongPre
sammiequon
2016/06/03 21:34:31
Done.
|
| } |
| AutoclickControllerImpl::~AutoclickControllerImpl() { |
| @@ -116,6 +122,14 @@ int AutoclickControllerImpl::GetAutoclickDelay() const { |
| return delay_ms_; |
| } |
| +void AutoclickControllerImpl::StartRingDisplay(ui::LocatedEvent* event) { |
| + autoclick_ring_display_->ProcessEvent(event, delay_ms_, true); |
| +} |
| + |
| +void AutoclickControllerImpl::StopRingDisplay(ui::LocatedEvent* event) { |
| + autoclick_ring_display_->ProcessEvent(event, delay_ms_, false); |
| +} |
| + |
| void AutoclickControllerImpl::InitClickTimer() { |
| autoclick_timer_.reset(new base::Timer( |
| FROM_HERE, |
| @@ -144,12 +158,15 @@ void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) { |
| if (delta.LengthSquared() >= kMovementThreshold * kMovementThreshold) { |
| anchor_location_ = mouse_location; |
| autoclick_timer_->Reset(); |
| + StartRingDisplay(event); |
| } |
| } else if (event->type() == ui::ET_MOUSE_PRESSED) { |
| autoclick_timer_->Stop(); |
| + StopRingDisplay(event); |
| } else if (event->type() == ui::ET_MOUSEWHEEL && |
| autoclick_timer_->IsRunning()) { |
| autoclick_timer_->Reset(); |
| + StartRingDisplay(event); |
| } |
| } |
| @@ -160,20 +177,25 @@ void AutoclickControllerImpl::OnKeyEvent(ui::KeyEvent* event) { |
| int new_modifiers = event->flags() & modifier_mask; |
| mouse_event_flags_ = (mouse_event_flags_ & ~modifier_mask) | new_modifiers; |
| - if (!IsModifierKey(event->key_code())) |
| + if (!IsModifierKey(event->key_code())) { |
| autoclick_timer_->Stop(); |
| + StopRingDisplay(NULL); |
|
jdufault
2016/05/31 19:06:15
nit: nullptr
sammiequon
2016/06/03 21:34:30
Done.
|
| + } |
| } |
| void AutoclickControllerImpl::OnTouchEvent(ui::TouchEvent* event) { |
| autoclick_timer_->Stop(); |
| + StopRingDisplay(event); |
| } |
| void AutoclickControllerImpl::OnGestureEvent(ui::GestureEvent* event) { |
| autoclick_timer_->Stop(); |
| + StopRingDisplay(event); |
| } |
| void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { |
| autoclick_timer_->Stop(); |
| + StopRingDisplay(event); |
| } |
| void AutoclickControllerImpl::DoAutoclick() { |