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,
// AutoclickControllerCommonDelegate overrides:
views::Widget* CreateAutoclickRingWidget(
const gfx::Point& event_location) override;
const gfx::Point& point_in_screen) override;
void UpdateAutoclickRingWidget(views::Widget* widget,
const gfx::Point& event_location) override;
void DoAutoclick(const gfx::Point& event_location,
const gfx::Point& point_in_screen) override;
void DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) override;
void OnAutoclickCanceled() override;
......@@ -136,8 +136,8 @@ void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) {
}
views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget(
const gfx::Point& event_location) {
aura::Window* target = ash::wm::GetRootWindowAt(event_location);
const gfx::Point& point_in_screen) {
aura::Window* target = ash::wm::GetRootWindowAt(point_in_screen);
SetTapDownTarget(target);
aura::Window* root_window = target->GetRootWindow();
widget_.reset(new views::Widget);
......@@ -157,8 +157,8 @@ views::Widget* AutoclickControllerImpl::CreateAutoclickRingWidget(
void AutoclickControllerImpl::UpdateAutoclickRingWidget(
views::Widget* widget,
const gfx::Point& event_location) {
aura::Window* target = ash::wm::GetRootWindowAt(event_location);
const gfx::Point& point_in_screen) {
aura::Window* target = ash::wm::GetRootWindowAt(point_in_screen);
SetTapDownTarget(target);
aura::Window* root_window = target->GetRootWindow();
if (widget->GetNativeView()->GetRootWindow() != root_window) {
......@@ -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) {
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.";
gfx::Point click_location(event_location);
::wm::ConvertPointFromScreen(root_window, &click_location);
gfx::Point location_in_pixels(point_in_screen);
::wm::ConvertPointFromScreen(root_window, &location_in_pixels);
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,
click_location, ui::EventTimeForNow(),
ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, location_in_pixels,
location_in_pixels, ui::EventTimeForNow(),
mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, click_location,
click_location, ui::EventTimeForNow(),
ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, location_in_pixels,
location_in_pixels, ui::EventTimeForNow(),
mouse_event_flags | ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
......@@ -191,8 +191,6 @@ void AutoclickControllerImpl::DoAutoclick(const gfx::Point& event_location,
host->event_sink()->OnEventFromSource(&press_event);
if (!details.dispatcher_destroyed)
details = host->event_sink()->OnEventFromSource(&release_event);
if (details.dispatcher_destroyed)
return;
}
void AutoclickControllerImpl::OnAutoclickCanceled() {
......
......@@ -5,8 +5,6 @@
#ifndef ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_DELEGATE_H
#define ASH_AUTOCLICK_COMMON_AUTOCLICK_CONTROLLER_COMMON_DELEGATE_H
#include "base/macros.h"
namespace views {
class Widget;
}
......@@ -19,27 +17,25 @@ namespace ash {
class AutoclickControllerCommonDelegate {
public:
AutoclickControllerCommonDelegate() {}
virtual ~AutoclickControllerCommonDelegate() {}
// Creates a ring widget at |event_location|.
// Creates a ring widget at |point_in_screen|.
// AutoclickControllerCommonDelegate still has ownership of the widget they
// created.
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,
const gfx::Point& event_location) = 0;
const gfx::Point& point_in_screen) = 0;
// Generates a click with |mouse_event_flags| at |event_location|.
virtual void DoAutoclick(const gfx::Point& event_location,
// Generates a click with |mouse_event_flags| at |point_in_screen|.
virtual void DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) = 0;
virtual void OnAutoclickCanceled() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(AutoclickControllerCommonDelegate);
protected:
virtual ~AutoclickControllerCommonDelegate() {}
};
} // namespace ash
......
......@@ -154,17 +154,17 @@ void AutoclickApplication::BindAutoclickControllerRequest(
}
views::Widget* AutoclickApplication::CreateAutoclickRingWidget(
const gfx::Point& event_location) {
const gfx::Point& point_in_screen) {
return widget_.get();
}
void AutoclickApplication::UpdateAutoclickRingWidget(
views::Widget* widget,
const gfx::Point& event_location) {
const gfx::Point& point_in_screen) {
// 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) {
// TODO(riajiang): Currently not working. Need to know how to generate events
// in mus world. https://crbug.com/628665
......
......@@ -54,10 +54,10 @@ class AutoclickApplication : public service_manager::Service,
// ash::AutoclickControllerCommonDelegate:
views::Widget* CreateAutoclickRingWidget(
const gfx::Point& event_location) override;
const gfx::Point& point_in_screen) override;
void UpdateAutoclickRingWidget(views::Widget* widget,
const gfx::Point& event_location) override;
void DoAutoclick(const gfx::Point& event_location,
const gfx::Point& point_in_screen) override;
void DoAutoclick(const gfx::Point& point_in_screen,
const int mouse_event_flags) 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