| 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" | |
| 8 #include "ash/autoclick/common/autoclick_controller_common.h" | 7 #include "ash/autoclick/common/autoclick_controller_common.h" |
| 9 #include "ash/autoclick/common/autoclick_controller_common_delegate.h" | 8 #include "ash/autoclick/common/autoclick_controller_common_delegate.h" |
| 10 #include "ash/common/wm/root_window_finder.h" | 9 #include "ash/common/wm/root_window_finder.h" |
| 10 #include "ash/common/wm_window.h" |
| 11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 15 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
| 16 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
| 17 #include "ui/events/event_handler.h" | 17 #include "ui/events/event_handler.h" |
| 18 #include "ui/events/event_processor.h" | 18 #include "ui/events/event_processor.h" |
| 19 #include "ui/events/event_utils.h" | 19 #include "ui/events/event_utils.h" |
| 20 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 autoclick_controller_common_->CancelAutoclick(); | 132 autoclick_controller_common_->CancelAutoclick(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { | 135 void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { |
| 136 autoclick_controller_common_->CancelAutoclick(); | 136 autoclick_controller_common_->CancelAutoclick(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget( | 139 views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget( |
| 140 const gfx::Point& event_location) { | 140 const gfx::Point& event_location) { |
| 141 aura::Window* target = | 141 aura::Window* target = |
| 142 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); | 142 WmWindow::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); |
| 143 SetTapDownTarget(target); | 143 SetTapDownTarget(target); |
| 144 aura::Window* root_window = target->GetRootWindow(); | 144 aura::Window* root_window = target->GetRootWindow(); |
| 145 widget_.reset(new views::Widget); | 145 widget_.reset(new views::Widget); |
| 146 views::Widget::InitParams params; | 146 views::Widget::InitParams params; |
| 147 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 147 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 148 params.accept_events = false; | 148 params.accept_events = false; |
| 149 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; | 149 params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; |
| 150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 151 params.context = root_window; | 151 params.context = root_window; |
| 152 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 152 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 153 params.parent = | 153 params.parent = |
| 154 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer); | 154 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer); |
| 155 widget_->Init(params); | 155 widget_->Init(params); |
| 156 widget_->SetOpacity(1.f); | 156 widget_->SetOpacity(1.f); |
| 157 return widget_.get(); | 157 return widget_.get(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void AutoclickControllerImpl::UpdateAutoclickRingWidget( | 160 void AutoclickControllerImpl::UpdateAutoclickRingWidget( |
| 161 views::Widget* widget, | 161 views::Widget* widget, |
| 162 const gfx::Point& event_location) { | 162 const gfx::Point& event_location) { |
| 163 aura::Window* target = | 163 aura::Window* target = |
| 164 WmWindowAura::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); | 164 WmWindow::GetAuraWindow(ash::wm::GetRootWindowAt(event_location)); |
| 165 SetTapDownTarget(target); | 165 SetTapDownTarget(target); |
| 166 aura::Window* root_window = target->GetRootWindow(); | 166 aura::Window* root_window = target->GetRootWindow(); |
| 167 if (widget->GetNativeView()->GetRootWindow() != root_window) { | 167 if (widget->GetNativeView()->GetRootWindow() != root_window) { |
| 168 views::Widget::ReparentNativeView( | 168 views::Widget::ReparentNativeView( |
| 169 widget->GetNativeView(), | 169 widget->GetNativeView(), |
| 170 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer)); | 170 Shell::GetContainer(root_window, kShellWindowId_OverlayContainer)); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void AutoclickControllerImpl::DoAutoclick(const gfx::Point& event_location, | 174 void AutoclickControllerImpl::DoAutoclick(const gfx::Point& event_location, |
| 175 const int mouse_event_flags) { | 175 const int mouse_event_flags) { |
| 176 aura::Window* root_window = | 176 aura::Window* root_window = |
| 177 WmWindowAura::GetAuraWindow(wm::GetRootWindowAt(event_location)); | 177 WmWindow::GetAuraWindow(wm::GetRootWindowAt(event_location)); |
| 178 DCHECK(root_window) << "Root window not found while attempting autoclick."; | 178 DCHECK(root_window) << "Root window not found while attempting autoclick."; |
| 179 | 179 |
| 180 gfx::Point click_location(event_location); | 180 gfx::Point click_location(event_location); |
| 181 ::wm::ConvertPointFromScreen(root_window, &click_location); | 181 ::wm::ConvertPointFromScreen(root_window, &click_location); |
| 182 aura::WindowTreeHost* host = root_window->GetHost(); | 182 aura::WindowTreeHost* host = root_window->GetHost(); |
| 183 host->ConvertDIPToPixels(&click_location); | 183 host->ConvertDIPToPixels(&click_location); |
| 184 | 184 |
| 185 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, click_location, | 185 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, click_location, |
| 186 click_location, ui::EventTimeForNow(), | 186 click_location, ui::EventTimeForNow(), |
| 187 mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON, | 187 mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 207 DCHECK_EQ(tap_down_target_, window); | 207 DCHECK_EQ(tap_down_target_, window); |
| 208 autoclick_controller_common_->CancelAutoclick(); | 208 autoclick_controller_common_->CancelAutoclick(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 // static. | 211 // static. |
| 212 AutoclickController* AutoclickController::CreateInstance() { | 212 AutoclickController* AutoclickController::CreateInstance() { |
| 213 return new AutoclickControllerImpl(); | 213 return new AutoclickControllerImpl(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace ash | 216 } // namespace ash |
| OLD | NEW |