Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/autoclick/autoclick_controller.h" | 5 #include "ash/autoclick/autoclick_controller.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/autoclick/common/autoclick_controller_common.h" | 8 #include "ash/autoclick/common/autoclick_controller_common.h" |
| 9 #include "ash/autoclick/common/autoclick_controller_common_delegate.h" | 9 #include "ash/autoclick/common/autoclick_controller_common_delegate.h" |
| 10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 void SetAutoclickDelay(base::TimeDelta delay) override; | 46 void SetAutoclickDelay(base::TimeDelta delay) override; |
| 47 | 47 |
| 48 // ui::EventHandler overrides: | 48 // ui::EventHandler overrides: |
| 49 void OnMouseEvent(ui::MouseEvent* event) override; | 49 void OnMouseEvent(ui::MouseEvent* event) override; |
| 50 void OnKeyEvent(ui::KeyEvent* event) override; | 50 void OnKeyEvent(ui::KeyEvent* event) override; |
| 51 void OnTouchEvent(ui::TouchEvent* event) override; | 51 void OnTouchEvent(ui::TouchEvent* event) override; |
| 52 void OnGestureEvent(ui::GestureEvent* event) override; | 52 void OnGestureEvent(ui::GestureEvent* event) override; |
| 53 void OnScrollEvent(ui::ScrollEvent* event) override; | 53 void OnScrollEvent(ui::ScrollEvent* event) override; |
| 54 | 54 |
| 55 // AutoclickControllerCommonDelegate overrides: | 55 // AutoclickControllerCommonDelegate overrides: |
| 56 std::unique_ptr<views::Widget> CreateAutoclickRingWidget( | 56 views::Widget* CreateAutoclickRingWidget( |
| 57 const gfx::Point& event_location) override; | 57 const gfx::Point& event_location) override; |
| 58 void UpdateAutoclickRingWidget(views::Widget* widget, | 58 void UpdateAutoclickRingWidget(views::Widget* widget, |
| 59 const gfx::Point& event_location) override; | 59 const gfx::Point& event_location) override; |
| 60 void DoAutoclick(const gfx::Point& event_location, | 60 void DoAutoclick(const gfx::Point& event_location, |
| 61 const int mouse_event_flags) override; | 61 const int mouse_event_flags) override; |
| 62 void OnAutoclickCanceled() override; | 62 void OnAutoclickCanceled() override; |
| 63 | 63 |
| 64 // aura::WindowObserver overrides: | 64 // aura::WindowObserver overrides: |
| 65 void OnWindowDestroying(aura::Window* window) override; | 65 void OnWindowDestroying(aura::Window* window) override; |
| 66 | 66 |
| 67 bool enabled_; | 67 bool enabled_; |
| 68 // The target window is observed by AutoclickControllerImpl for the duration | 68 // The target window is observed by AutoclickControllerImpl for the duration |
| 69 // of a autoclick gesture. | 69 // of a autoclick gesture. |
| 70 aura::Window* tap_down_target_; | 70 aura::Window* tap_down_target_; |
| 71 std::unique_ptr<views::Widget> widget_; | |
| 71 std::unique_ptr<AutoclickControllerCommon> autoclick_controller_common_; | 72 std::unique_ptr<AutoclickControllerCommon> autoclick_controller_common_; |
| 72 | 73 |
| 73 DISALLOW_COPY_AND_ASSIGN(AutoclickControllerImpl); | 74 DISALLOW_COPY_AND_ASSIGN(AutoclickControllerImpl); |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 AutoclickControllerImpl::AutoclickControllerImpl() | 77 AutoclickControllerImpl::AutoclickControllerImpl() |
| 77 : enabled_(false), | 78 : enabled_(false), |
| 78 tap_down_target_(nullptr), | 79 tap_down_target_(nullptr), |
| 80 widget_(nullptr), | |
|
sky
2016/09/09 21:42:29
Remove as this is unnecessary.
riajiang
2016/09/12 16:15:46
Done.
| |
| 79 autoclick_controller_common_( | 81 autoclick_controller_common_( |
| 80 new AutoclickControllerCommon(GetDefaultAutoclickDelay(), this)) {} | 82 new AutoclickControllerCommon(GetDefaultAutoclickDelay(), this)) {} |
| 81 | 83 |
| 82 AutoclickControllerImpl::~AutoclickControllerImpl() { | 84 AutoclickControllerImpl::~AutoclickControllerImpl() { |
| 83 SetTapDownTarget(nullptr); | 85 SetTapDownTarget(nullptr); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void AutoclickControllerImpl::SetTapDownTarget(aura::Window* target) { | 88 void AutoclickControllerImpl::SetTapDownTarget(aura::Window* target) { |
| 87 if (tap_down_target_ == target) | 89 if (tap_down_target_ == target) |
| 88 return; | 90 return; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 109 | 111 |
| 110 bool AutoclickControllerImpl::IsEnabled() const { | 112 bool AutoclickControllerImpl::IsEnabled() const { |
| 111 return enabled_; | 113 return enabled_; |
| 112 } | 114 } |
| 113 | 115 |
| 114 void AutoclickControllerImpl::SetAutoclickDelay(base::TimeDelta delay) { | 116 void AutoclickControllerImpl::SetAutoclickDelay(base::TimeDelta delay) { |
| 115 autoclick_controller_common_->SetAutoclickDelay(delay); | 117 autoclick_controller_common_->SetAutoclickDelay(delay); |
| 116 } | 118 } |
| 117 | 119 |
| 118 void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) { | 120 void AutoclickControllerImpl::OnMouseEvent(ui::MouseEvent* event) { |
| 119 autoclick_controller_common_->HandleMouseEvent(*event); | 121 autoclick_controller_common_->HandleMouseEvent(ui::PointerEvent(*event)); |
| 120 } | 122 } |
| 121 | 123 |
| 122 void AutoclickControllerImpl::OnKeyEvent(ui::KeyEvent* event) { | 124 void AutoclickControllerImpl::OnKeyEvent(ui::KeyEvent* event) { |
| 123 autoclick_controller_common_->HandleKeyEvent(*event); | 125 autoclick_controller_common_->HandleKeyEvent(*event); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void AutoclickControllerImpl::OnTouchEvent(ui::TouchEvent* event) { | 128 void AutoclickControllerImpl::OnTouchEvent(ui::TouchEvent* event) { |
| 127 autoclick_controller_common_->CancelAutoclick(); | 129 autoclick_controller_common_->CancelAutoclick(); |
| 128 } | 130 } |
| 129 | 131 |
| 130 void AutoclickControllerImpl::OnGestureEvent(ui::GestureEvent* event) { | 132 void AutoclickControllerImpl::OnGestureEvent(ui::GestureEvent* event) { |
| 131 autoclick_controller_common_->CancelAutoclick(); | 133 autoclick_controller_common_->CancelAutoclick(); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { | 136 void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { |
| 135 autoclick_controller_common_->CancelAutoclick(); | 137 autoclick_controller_common_->CancelAutoclick(); |
| 136 } | 138 } |
| 137 | 139 |
| 138 std::unique_ptr<views::Widget> | 140 views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget( |
| 139 AutoclickControllerImpl::CreateAutoclickRingWidget( | |
| 140 const gfx::Point& event_location) { | 141 const gfx::Point& event_location) { |
| 141 aura::Window* target = | 142 aura::Window* target = |
| 142 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); | 143 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); |
| 143 SetTapDownTarget(target); | 144 SetTapDownTarget(target); |
| 144 aura::Window* root_window = target->GetRootWindow(); | 145 aura::Window* root_window = target->GetRootWindow(); |
| 145 std::unique_ptr<views::Widget> widget(new views::Widget); | 146 widget_.reset(new views::Widget); |
| 146 views::Widget::InitParams params; | 147 views::Widget::InitParams params; |
| 147 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 148 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 148 params.accept_events = false; | 149 params.accept_events = false; |
| 149 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 150 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| 150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 151 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 151 params.context = root_window; | 152 params.context = root_window; |
| 152 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 153 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 153 params.parent = | 154 params.parent = |
| 154 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer); | 155 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer); |
| 155 widget->Init(params); | 156 widget_->Init(params); |
| 156 widget->SetOpacity(1.f); | 157 widget_->SetOpacity(1.f); |
| 157 return widget; | 158 return widget_.get(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 void AutoclickControllerImpl::UpdateAutoclickRingWidget( | 161 void AutoclickControllerImpl::UpdateAutoclickRingWidget( |
| 161 views::Widget* widget, | 162 views::Widget* widget, |
| 162 const gfx::Point& event_location) { | 163 const gfx::Point& event_location) { |
| 163 aura::Window* target = | 164 aura::Window* target = |
| 164 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); | 165 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); |
| 165 SetTapDownTarget(target); | 166 SetTapDownTarget(target); |
| 166 aura::Window* root_window = target->GetRootWindow(); | 167 aura::Window* root_window = target->GetRootWindow(); |
| 167 if (widget->GetNativeView()->GetRootWindow() != root_window) { | 168 if (widget->GetNativeView()->GetRootWindow() != root_window) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 DCHECK_EQ(tap_down_target_, window); | 208 DCHECK_EQ(tap_down_target_, window); |
| 208 autoclick_controller_common_->CancelAutoclick(); | 209 autoclick_controller_common_->CancelAutoclick(); |
| 209 } | 210 } |
| 210 | 211 |
| 211 // static. | 212 // static. |
| 212 AutoclickController* AutoclickController::CreateInstance() { | 213 AutoclickController* AutoclickController::CreateInstance() { |
| 213 return new AutoclickControllerImpl(); | 214 return new AutoclickControllerImpl(); |
| 214 } | 215 } |
| 215 | 216 |
| 216 } // namespace ash | 217 } // namespace ash |
| OLD | NEW |