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/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/coordinate_conversion.h" | 8 #include "ash/wm/coordinate_conversion.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void AutoclickControllerImpl::DoAutoclick() { | 179 void AutoclickControllerImpl::DoAutoclick() { |
180 gfx::Point screen_location = | 180 gfx::Point screen_location = |
181 aura::Env::GetInstance()->last_mouse_location(); | 181 aura::Env::GetInstance()->last_mouse_location(); |
182 aura::Window* root_window = wm::GetRootWindowAt(screen_location); | 182 aura::Window* root_window = wm::GetRootWindowAt(screen_location); |
183 DCHECK(root_window) << "Root window not found while attempting autoclick."; | 183 DCHECK(root_window) << "Root window not found while attempting autoclick."; |
184 | 184 |
185 gfx::Point click_location(screen_location); | 185 gfx::Point click_location(screen_location); |
186 anchor_location_ = click_location; | 186 anchor_location_ = click_location; |
187 wm::ConvertPointFromScreen(root_window, &click_location); | 187 wm::ConvertPointFromScreen(root_window, &click_location); |
188 | 188 |
189 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 189 aura::WindowTreeHost* host = root_window->GetHost(); |
190 dispatcher->host()->ConvertPointToHost(&click_location); | 190 host->ConvertPointToHost(&click_location); |
191 | 191 |
192 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, | 192 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, |
193 click_location, | 193 click_location, |
194 click_location, | 194 click_location, |
195 mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON, | 195 mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON, |
196 ui::EF_LEFT_MOUSE_BUTTON); | 196 ui::EF_LEFT_MOUSE_BUTTON); |
197 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, | 197 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, |
198 click_location, | 198 click_location, |
199 click_location, | 199 click_location, |
200 mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON, | 200 mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON, |
201 ui::EF_LEFT_MOUSE_BUTTON); | 201 ui::EF_LEFT_MOUSE_BUTTON); |
202 | 202 |
203 ui::EventDispatchDetails details = | 203 ui::EventDispatchDetails details = |
204 dispatcher->OnEventFromSource(&press_event); | 204 host->dispatcher()->OnEventFromSource(&press_event); |
205 if (!details.dispatcher_destroyed) | 205 if (!details.dispatcher_destroyed) |
206 details = dispatcher->OnEventFromSource(&release_event); | 206 details = host->dispatcher()->OnEventFromSource(&release_event); |
207 if (details.dispatcher_destroyed) | 207 if (details.dispatcher_destroyed) |
208 return; | 208 return; |
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 |