| Index: ash/autoclick/common/autoclick_ring_handler.cc
|
| diff --git a/chrome/browser/chromeos/ui/autoclick_ring_handler.cc b/ash/autoclick/common/autoclick_ring_handler.cc
|
| similarity index 77%
|
| rename from chrome/browser/chromeos/ui/autoclick_ring_handler.cc
|
| rename to ash/autoclick/common/autoclick_ring_handler.cc
|
| index c0e3fda8471e31e2b30e975033968176995361e8..1f85fca74b40cd99e080e9e04dc56978dbd254cc 100644
|
| --- a/chrome/browser/chromeos/ui/autoclick_ring_handler.cc
|
| +++ b/ash/autoclick/common/autoclick_ring_handler.cc
|
| @@ -2,31 +2,20 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/chromeos/ui/autoclick_ring_handler.h"
|
| +#include "ash/autoclick/common/autoclick_ring_handler.h"
|
|
|
| -#include <memory>
|
| -
|
| -#include "ash/aura/wm_window_aura.h"
|
| -#include "ash/common/shell_window_ids.h"
|
| -#include "ash/common/wm/root_window_finder.h"
|
| -#include "ash/root_window_controller.h"
|
| -#include "ash/shell.h"
|
| #include "third_party/skia/include/core/SkColor.h"
|
| #include "third_party/skia/include/core/SkPaint.h"
|
| #include "third_party/skia/include/core/SkPath.h"
|
| #include "third_party/skia/include/core/SkRect.h"
|
| -#include "ui/aura/client/screen_position_client.h"
|
| -#include "ui/aura/env.h"
|
| #include "ui/aura/window.h"
|
| -#include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/compositor/layer.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/transform.h"
|
| #include "ui/views/view.h"
|
| #include "ui/views/widget/widget.h"
|
| -#include "ui/wm/core/coordinate_conversion.h"
|
|
|
| -namespace chromeos {
|
| +namespace ash {
|
| namespace {
|
|
|
| const int kAutoclickRingOuterRadius = 30;
|
| @@ -56,23 +45,6 @@ const SkColor kAutoclickRingArcColor = SkColorSetARGB(255, 0, 255, 0);
|
| const SkColor kAutoclickRingCircleColor = SkColorSetARGB(255, 0, 0, 255);
|
| const int kAutoclickRingFrameRateHz = 60;
|
|
|
| -views::Widget* CreateAutoclickRingWidget(aura::Window* root_window) {
|
| - views::Widget* widget = new views::Widget;
|
| - views::Widget::InitParams params;
|
| - params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
|
| - params.accept_events = false;
|
| - params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
|
| - params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| - params.context = root_window;
|
| - params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
|
| - params.parent = ash::Shell::GetContainer(
|
| - root_window, ash::kShellWindowId_OverlayContainer);
|
| -
|
| - widget->Init(params);
|
| - widget->SetOpacity(1.f);
|
| - return widget;
|
| -}
|
| -
|
| void PaintAutoclickRingCircle(gfx::Canvas* canvas,
|
| gfx::Point& center,
|
| int radius) {
|
| @@ -109,22 +81,22 @@ void PaintAutoclickRingArc(gfx::Canvas* canvas,
|
| // animation is shown in.
|
| class AutoclickRingHandler::AutoclickRingView : public views::View {
|
| public:
|
| - AutoclickRingView(const gfx::Point& event_location, aura::Window* root_window)
|
| + AutoclickRingView(const gfx::Point& event_location,
|
| + views::Widget* ring_widget)
|
| : views::View(),
|
| - widget_(CreateAutoclickRingWidget(root_window)),
|
| + widget_(ring_widget),
|
| current_angle_(kAutoclickRingAngleStartValue),
|
| current_scale_(kAutoclickRingScaleStartValue) {
|
| widget_->SetContentsView(this);
|
|
|
| // We are owned by the AutoclickRingHandler.
|
| set_owned_by_client();
|
| - SetNewLocation(event_location, root_window);
|
| + SetNewLocation(event_location);
|
| }
|
|
|
| ~AutoclickRingView() override {}
|
|
|
| - void SetNewLocation(const gfx::Point& new_event_location,
|
| - aura::Window* root_window) {
|
| + void SetNewLocation(const gfx::Point& new_event_location) {
|
| gfx::Point point = new_event_location;
|
| widget_->SetBounds(gfx::Rect(
|
| point.x() - (kAutoclickRingOuterRadius + kAutoclickRingGlowWidth),
|
| @@ -186,7 +158,7 @@ class AutoclickRingHandler::AutoclickRingView : public views::View {
|
| canvas->Restore();
|
| }
|
|
|
| - std::unique_ptr<views::Widget> widget_;
|
| + views::Widget* widget_;
|
| int current_angle_;
|
| double current_scale_;
|
|
|
| @@ -198,6 +170,7 @@ class AutoclickRingHandler::AutoclickRingView : public views::View {
|
| // AutoclickRingHandler, public
|
| AutoclickRingHandler::AutoclickRingHandler()
|
| : gfx::LinearAnimation(kAutoclickRingFrameRateHz, nullptr),
|
| + ring_widget_(nullptr),
|
| tap_down_target_(nullptr),
|
| current_animation_type_(AnimationType::NONE) {}
|
|
|
| @@ -207,57 +180,44 @@ AutoclickRingHandler::~AutoclickRingHandler() {
|
|
|
| void AutoclickRingHandler::StartGesture(
|
| base::TimeDelta duration,
|
| - const gfx::Point& center_point_in_screen) {
|
| - aura::Window* target = GetTargetWindow();
|
| - if (tap_down_target_ && tap_down_target_ != target)
|
| - return;
|
| + const gfx::Point& center_point_in_screen,
|
| + aura::Window* target,
|
| + views::Widget* widget) {
|
| StopAutoclickRing();
|
| - SetTapDownTarget();
|
| tap_down_location_ = center_point_in_screen;
|
| + SetTapDownTarget(target);
|
| + ring_widget_ = widget;
|
| current_animation_type_ = AnimationType::GROW_ANIMATION;
|
| animation_duration_ = duration;
|
| StartAnimation(base::TimeDelta());
|
| }
|
|
|
| void AutoclickRingHandler::StopGesture() {
|
| - aura::Window* target = GetTargetWindow();
|
| - if (tap_down_target_ && tap_down_target_ != target)
|
| - return;
|
| StopAutoclickRing();
|
| }
|
|
|
| void AutoclickRingHandler::SetGestureCenter(
|
| - const gfx::Point& center_point_in_screen) {
|
| + const gfx::Point& center_point_in_screen,
|
| + aura::Window* target,
|
| + views::Widget* widget) {
|
| tap_down_location_ = center_point_in_screen;
|
| + SetTapDownTarget(target);
|
| + ring_widget_ = widget;
|
| }
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| // AutoclickRingHandler, private
|
| -aura::Window* AutoclickRingHandler::GetTargetWindow() {
|
| - aura::Window* target = ash::WmWindowAura::GetAuraWindow(
|
| - ash::wm::GetRootWindowAt(tap_down_location_));
|
| - DCHECK(target) << "Root window not found while rendering autoclick circle;";
|
| - return target;
|
| -}
|
| -
|
| -void AutoclickRingHandler::SetTapDownTarget() {
|
| - aura::Window* target = GetTargetWindow();
|
| - SetTapDownTarget(target);
|
| -}
|
| -
|
| void AutoclickRingHandler::StartAnimation(base::TimeDelta delay) {
|
| int delay_ms = int{delay.InMilliseconds()};
|
| switch (current_animation_type_) {
|
| case AnimationType::GROW_ANIMATION: {
|
| - aura::Window* root_window = tap_down_target_->GetRootWindow();
|
| - view_.reset(new AutoclickRingView(tap_down_location_, root_window));
|
| + view_.reset(new AutoclickRingView(tap_down_location_, ring_widget_));
|
| SetDuration(delay_ms);
|
| Start();
|
| break;
|
| }
|
| case AnimationType::SHRINK_ANIMATION: {
|
| - aura::Window* root_window = tap_down_target_->GetRootWindow();
|
| - view_.reset(new AutoclickRingView(tap_down_location_, root_window));
|
| + view_.reset(new AutoclickRingView(tap_down_location_, ring_widget_));
|
| SetDuration(delay_ms);
|
| Start();
|
| break;
|
| @@ -293,11 +253,11 @@ void AutoclickRingHandler::AnimateToState(double state) {
|
| DCHECK(view_.get());
|
| switch (current_animation_type_) {
|
| case AnimationType::GROW_ANIMATION:
|
| - view_->SetNewLocation(tap_down_location_, GetTargetWindow());
|
| + view_->SetNewLocation(tap_down_location_);
|
| view_->UpdateWithGrowAnimation(this);
|
| break;
|
| case AnimationType::SHRINK_ANIMATION:
|
| - view_->SetNewLocation(tap_down_location_, GetTargetWindow());
|
| + view_->SetNewLocation(tap_down_location_);
|
| view_->UpdateWithShrinkAnimation(this);
|
| break;
|
| case AnimationType::NONE:
|
| @@ -328,4 +288,4 @@ void AutoclickRingHandler::OnWindowDestroying(aura::Window* window) {
|
| StopAutoclickRing();
|
| }
|
|
|
| -} // namespace chromeos
|
| +} // namespace ash
|
|
|