Commit c1be333d authored by James Cook's avatar James Cook Committed by Commit Bot

cros: Clean up AutoclickControllerCommonDelegate

Specify the coordinate system in variable names for points.

Bug: 821471
Change-Id: I5368b85e6c1c36f5295eee10b96074e5d3b30403
Reviewed-on: https://chromium-review.googlesource.com/961663Reviewed-by: default avatarRia Jiang <riajiang@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543088}
parent ea2a0501
...@@ -53,10 +53,10 @@ class AutoclickControllerImpl : public AutoclickController, ...@@ -53,10 +53,10 @@ class AutoclickControllerImpl : public AutoclickController,
// AutoclickControllerCommonDelegate overrides: // AutoclickControllerCommonDelegate overrides:
views::Widget* CreateAutoclickRingWidget( views::Widget* CreateAutoclickRingWidget(
const gfx::Point& event_location) override; const gfx::Point& point_in_screen) override;
void UpdateAutoclickRingWidget(views::Widget* widget, void UpdateAutoclickRingWidget(views::Widget* widget,
const gfx::Point& event_location) override; const gfx::Point& point_in_screen) override;
void DoAutoclick(const gfx::Point& event_location, void DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) override; const int mouse_event_flags) override;
void OnAutoclickCanceled() override; void OnAutoclickCanceled() override;
...@@ -136,8 +136,8 @@ void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) { ...@@ -136,8 +136,8 @@ void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) {
} }
views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget( views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget(
const gfx::Point& event_location) { const gfx::Point& point_in_screen) {
aura::Window* target = ash::wm::GetRootWindowAt(event_location); aura::Window* target = ash::wm::GetRootWindowAt(point_in_screen);
SetTapDownTarget(target); SetTapDownTarget(target);
aura::Window* root_window = target->GetRootWindow(); aura::Window* root_window = target->GetRootWindow();
widget_.reset(new views::Widget); widget_.reset(new views::Widget);
...@@ -157,8 +157,8 @@ views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget( ...@@ -157,8 +157,8 @@ views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget(
void AutoclickControllerImpl::UpdateAutoclickRingWidget( void AutoclickControllerImpl::UpdateAutoclickRingWidget(
views::Widget* widget, views::Widget* widget,
const gfx::Point& event_location) { const gfx::Point& point_in_screen) {
aura::Window* target = ash::wm::GetRootWindowAt(event_location); aura::Window* target = ash::wm::GetRootWindowAt(point_in_screen);
SetTapDownTarget(target); SetTapDownTarget(target);
aura::Window* root_window = target->GetRootWindow(); aura::Window* root_window = target->GetRootWindow();
if (widget->GetNativeView()->GetRootWindow() != root_window) { if (widget->GetNativeView()->GetRootWindow() != root_window) {
...@@ -168,22 +168,22 @@ void AutoclickControllerImpl::UpdateAutoclickRingWidget( ...@@ -168,22 +168,22 @@ void AutoclickControllerImpl::UpdateAutoclickRingWidget(
} }
} }
void AutoclickControllerImpl::DoAutoclick(const gfx::Point& event_location, void AutoclickControllerImpl::DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) { const int mouse_event_flags) {
aura::Window* root_window = wm::GetRootWindowAt(event_location); aura::Window* root_window = wm::GetRootWindowAt(point_in_screen);
DCHECK(root_window) << "Root window not found while attempting autoclick."; DCHECK(root_window) << "Root window not found while attempting autoclick.";
gfx::Point click_location(event_location); gfx::Point location_in_pixels(point_in_screen);
::wm::ConvertPointFromScreen(root_window, &click_location); ::wm::ConvertPointFromScreen(root_window, &location_in_pixels);
aura::WindowTreeHost* host = root_window->GetHost(); aura::WindowTreeHost* host = root_window->GetHost();
host->ConvertDIPToPixels(&click_location); host->ConvertDIPToPixels(&location_in_pixels);
ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, click_location, ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, location_in_pixels,
click_location, ui::EventTimeForNow(), location_in_pixels, ui::EventTimeForNow(),
mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON, mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON); ui::EF_LEFT_MOUSE_BUTTON);
ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, click_location, ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, location_in_pixels,
click_location, ui::EventTimeForNow(), location_in_pixels, ui::EventTimeForNow(),
mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON, mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON); ui::EF_LEFT_MOUSE_BUTTON);
...@@ -191,8 +191,6 @@ void AutoclickControllerImpl::DoAutoclick(const gfx::Point& event_location, ...@@ -191,8 +191,6 @@ void AutoclickControllerImpl::DoAutoclick(const gfx::Point& event_location,
host->event_sink()->OnEventFromSource(&press_event); host->event_sink()->OnEventFromSource(&press_event);
if (!details.dispatcher_destroyed) if (!details.dispatcher_destroyed)
details = host->event_sink()->OnEventFromSource(&release_event); details = host->event_sink()->OnEventFromSource(&release_event);
if (details.dispatcher_destroyed)
return;
} }
void AutoclickControllerImpl::OnAutoclickCanceled() { void AutoclickControllerImpl::OnAutoclickCanceled() {
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_DELEGATE_H #ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_DELEGATE_H
#define ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_DELEGATE_H #define ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_DELEGATE_H
#include "base/macros.h"
namespace views { namespace views {
class Widget; class Widget;
} }
...@@ -19,27 +17,25 @@ namespace ash { ...@@ -19,27 +17,25 @@ namespace ash {
class AutoclickControllerCommonDelegate { class AutoclickControllerCommonDelegate {
public: public:
AutoclickControllerCommonDelegate() {} // Creates a ring widget at |point_in_screen|.
virtual ~AutoclickControllerCommonDelegate() {}
// Creates a ring widget at |event_location|.
// AutoclickControllerCommonDelegate still has ownership of the widget they // AutoclickControllerCommonDelegate still has ownership of the widget they
// created. // created.
virtual views::Widget* CreateAutoclickRingWidget( virtual views::Widget* CreateAutoclickRingWidget(
const gfx::Point& event_location) = 0; const gfx::Point& point_in_screen) = 0;
// Moves |widget| to |event_location|. // Moves |widget| to |point_in_screen|. The point may be on a different
// display.
virtual void UpdateAutoclickRingWidget(views::Widget* widget, virtual void UpdateAutoclickRingWidget(views::Widget* widget,
const gfx::Point& event_location) = 0; const gfx::Point& point_in_screen) = 0;
// Generates a click with |mouse_event_flags| at |event_location|. // Generates a click with |mouse_event_flags| at |point_in_screen|.
virtual void DoAutoclick(const gfx::Point& event_location, virtual void DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) = 0; const int mouse_event_flags) = 0;
virtual void OnAutoclickCanceled() = 0; virtual void OnAutoclickCanceled() = 0;
private: protected:
DISALLOW_COPY_AND_ASSIGN(AutoclickControllerCommonDelegate); virtual ~AutoclickControllerCommonDelegate() {}
}; };
} // namespace ash } // namespace ash
......
...@@ -154,17 +154,17 @@ void AutoclickApplication::BindAutoclickControllerRequest( ...@@ -154,17 +154,17 @@ void AutoclickApplication::BindAutoclickControllerRequest(
} }
views::Widget* AutoclickApplication::CreateAutoclickRingWidget( views::Widget* AutoclickApplication::CreateAutoclickRingWidget(
const gfx::Point& event_location) { const gfx::Point& point_in_screen) {
return widget_.get(); return widget_.get();
} }
void AutoclickApplication::UpdateAutoclickRingWidget( void AutoclickApplication::UpdateAutoclickRingWidget(
views::Widget* widget, views::Widget* widget,
const gfx::Point& event_location) { const gfx::Point& point_in_screen) {
// Not used in mus. // Not used in mus.
} }
void AutoclickApplication::DoAutoclick(const gfx::Point& event_location, void AutoclickApplication::DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) { const int mouse_event_flags) {
// TODO(riajiang): Currently not working. Need to know how to generate events // TODO(riajiang): Currently not working. Need to know how to generate events
// in mus world. https://crbug.com/628665 // in mus world. https://crbug.com/628665
......
...@@ -54,10 +54,10 @@ class AutoclickApplication : public service_manager::Service, ...@@ -54,10 +54,10 @@ class AutoclickApplication : public service_manager::Service,
// ash::AutoclickControllerCommonDelegate: // ash::AutoclickControllerCommonDelegate:
views::Widget* CreateAutoclickRingWidget( views::Widget* CreateAutoclickRingWidget(
const gfx::Point& event_location) override; const gfx::Point& point_in_screen) override;
void UpdateAutoclickRingWidget(views::Widget* widget, void UpdateAutoclickRingWidget(views::Widget* widget,
const gfx::Point& event_location) override; const gfx::Point& point_in_screen) override;
void DoAutoclick(const gfx::Point& event_location, void DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) override; const int mouse_event_flags) override;
void OnAutoclickCanceled() override; void OnAutoclickCanceled() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment