Commit 203ae029 authored by sammiequon's avatar sammiequon Committed by Commit bot

chromeos: Laser tool blocks events from propagating.

After discussion concluded the best way was to delegate the laser pointer out of ash/common. Moved all the laser related files into ash/laser.

LaserPointerController.* replaces LaserPointerMode.* and it inherits from EventHandler to grab the events and propagate them to LaserPointerView/LaserPointerPoints, which remain the same. LaserPointerMode just inherits common palette tool and calls the delegate.

BUG=644804
TEST=ash_unittests --gtest_filter="LaserPointer*"

https://screenshot.googleplex.com/BtwX1GTCpcW

Review-Url: https://codereview.chromium.org/2311393004
Cr-Commit-Position: refs/heads/master@{#419400}
parent 9ea2a739
......@@ -252,10 +252,6 @@ component("ash") {
"common/system/chromeos/palette/tools/create_note_action.h",
"common/system/chromeos/palette/tools/laser_pointer_mode.cc",
"common/system/chromeos/palette/tools/laser_pointer_mode.h",
"common/system/chromeos/palette/tools/laser_pointer_points.cc",
"common/system/chromeos/palette/tools/laser_pointer_points.h",
"common/system/chromeos/palette/tools/laser_pointer_view.cc",
"common/system/chromeos/palette/tools/laser_pointer_view.h",
"common/system/chromeos/palette/tools/magnifier_mode.cc",
"common/system/chromeos/palette/tools/magnifier_mode.h",
"common/system/chromeos/power/battery_notification.cc",
......@@ -651,8 +647,6 @@ component("ash") {
"link_handler_model_factory.h",
"magnifier/magnification_controller.cc",
"magnifier/magnification_controller.h",
"magnifier/partial_magnification_controller.cc",
"magnifier/partial_magnification_controller.h",
"metrics/desktop_task_switch_metric_recorder.cc",
"metrics/desktop_task_switch_metric_recorder.h",
"metrics/task_switch_metrics_recorder.cc",
......@@ -928,6 +922,17 @@ component("ash") {
data = [
"display/test_data/",
]
sources += [
"laser/laser_pointer_controller.cc",
"laser/laser_pointer_controller.h",
"laser/laser_pointer_points.cc",
"laser/laser_pointer_points.h",
"laser/laser_pointer_view.cc",
"laser/laser_pointer_view.h",
"magnifier/partial_magnification_controller.cc",
"magnifier/partial_magnification_controller.h",
]
} else {
sources -= [
"accelerators/key_hold_detector.cc",
......@@ -1128,6 +1133,13 @@ static_library("test_support_common") {
"//chromeos",
"//ui/display",
]
sources += [
"laser/laser_pointer_controller_test_api.cc",
"laser/laser_pointer_controller_test_api.h",
"laser/laser_pointer_points_test_api.cc",
"laser/laser_pointer_points_test_api.h",
]
}
}
......@@ -1375,11 +1387,6 @@ test("ash_unittests") {
"common/system/chromeos/palette/mock_palette_tool_delegate.h",
"common/system/chromeos/palette/palette_tool_manager_unittest.cc",
"common/system/chromeos/palette/tools/create_note_unittest.cc",
"common/system/chromeos/palette/tools/laser_pointer_mode_test_api.cc",
"common/system/chromeos/palette/tools/laser_pointer_mode_test_api.h",
"common/system/chromeos/palette/tools/laser_pointer_points_test_api.cc",
"common/system/chromeos/palette/tools/laser_pointer_points_test_api.h",
"common/system/chromeos/palette/tools/laser_pointer_unittest.cc",
"common/system/chromeos/palette/tools/screenshot_unittest.cc",
"common/system/chromeos/power/power_status_unittest.cc",
"common/system/chromeos/power/power_status_view_unittest.cc",
......@@ -1425,7 +1432,6 @@ test("ash_unittests") {
"frame/caption_buttons/frame_size_button_unittest.cc",
"host/ash_window_tree_host_x11_unittest.cc",
"magnifier/magnification_controller_unittest.cc",
"magnifier/partial_magnification_controller_unittest.cc",
"metrics/desktop_task_switch_metric_recorder_unittest.cc",
"metrics/task_switch_metrics_recorder_unittest.cc",
"metrics/task_switch_time_tracker_unittest.cc",
......@@ -1561,7 +1567,11 @@ test("ash_unittests") {
}
if (is_chromeos) {
sources += [ "first_run/first_run_helper_unittest.cc" ]
sources += [
"first_run/first_run_helper_unittest.cc",
"laser/laser_pointer_controller_unittest.cc",
"magnifier/partial_magnification_controller_unittest.cc",
]
deps += [
"//chromeos",
"//chromeos:power_manager_proto",
......@@ -1586,7 +1596,6 @@ test("ash_unittests") {
# TODO(zork): fix this test to build on Windows. See: crosbug.com/26906
"focus_cycler_unittest.cc",
"magnifier/magnification_controller_unittest.cc",
"magnifier/partial_magnification_controller_unittest.cc",
"sticky_keys/sticky_keys_overlay_unittest.cc",
"sticky_keys/sticky_keys_unittest.cc",
"touch/touchscreen_util_unittest.cc",
......
......@@ -18,6 +18,7 @@
#include "ash/common/wm_display_observer.h"
#include "ash/display/display_manager.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/laser/laser_pointer_controller.h"
#include "ash/metrics/task_switch_metrics_recorder.h"
#include "ash/shared/immersive_fullscreen_controller.h"
#include "ash/shell.h"
......@@ -284,6 +285,10 @@ void WmShellAura::ToggleIgnoreExternalKeyboard() {
->virtual_keyboard_controller()
->ToggleIgnoreExternalKeyboard();
}
void WmShellAura::SetLaserPointerEnabled(bool enabled) {
Shell::GetInstance()->laser_pointer_controller()->SetEnabled(enabled);
}
#endif
void WmShellAura::OnWindowActivated(
......
......@@ -84,6 +84,7 @@ class ASH_EXPORT WmShellAura : public WmShell,
bool IsTouchDown() override;
#if defined(OS_CHROMEOS)
void ToggleIgnoreExternalKeyboard() override;
void SetLaserPointerEnabled(bool enabled) override;
#endif
private:
......
......@@ -37,6 +37,8 @@ class PaletteDelegate {
virtual bool HasNoteApp() = 0;
// Enables or disables the partial magnifier.
// TODO(sammiequon): This can be removed from the delegate and put in wmshell.
// See http://crbug.com/647031.
virtual void SetPartialMagnifierState(bool enabled) = 0;
// Set callback that is run when a stylus is inserted or removed.
......@@ -62,10 +64,6 @@ class PaletteDelegate {
// Cancels any active partial screenshot session.
virtual void CancelPartialScreenshot() = 0;
// Called when the laser pointer has been enabled or disabled.
virtual void OnLaserPointerEnabled() = 0;
virtual void OnLaserPointerDisabled() = 0;
private:
DISALLOW_ASSIGN(PaletteDelegate);
};
......
......@@ -21,9 +21,9 @@ void PaletteTool::RegisterToolInstances(PaletteToolManager* tool_manager) {
tool_manager->AddTool(base::MakeUnique<CaptureRegionMode>(tool_manager));
tool_manager->AddTool(base::MakeUnique<CaptureScreenAction>(tool_manager));
tool_manager->AddTool(base::MakeUnique<CreateNoteAction>(tool_manager));
tool_manager->AddTool(base::MakeUnique<LaserPointerMode>(tool_manager));
if (ArePaletteExperimentalFeaturesEnabled())
tool_manager->AddTool(base::MakeUnique<MagnifierMode>(tool_manager));
tool_manager->AddTool(base::MakeUnique<LaserPointerMode>(tool_manager));
}
PaletteTool::PaletteTool(Delegate* delegate) : delegate_(delegate) {}
......
......@@ -6,44 +6,18 @@
#include "ash/common/palette_delegate.h"
#include "ash/common/system/chromeos/palette/palette_ids.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_view.h"
#include "ash/common/wm_shell.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/core/cursor_manager.h"
namespace ash {
namespace {
// A point gets removed from the collection if it is older than
// |kPointLifeDurationMs|.
const int kPointLifeDurationMs = 200;
// When no move events are being recieved we add a new point every
// |kAddStationaryPointsDelayMs| so that points older than
// |kPointLifeDurationMs| can get removed.
const int kAddStationaryPointsDelayMs = 5;
} // namespace
LaserPointerMode::LaserPointerMode(Delegate* delegate)
: CommonPaletteTool(delegate) {
laser_pointer_view_.reset(new LaserPointerView(
base::TimeDelta::FromMilliseconds(kPointLifeDurationMs)));
timer_.reset(new base::Timer(
FROM_HERE, base::TimeDelta::FromMilliseconds(kAddStationaryPointsDelayMs),
base::Bind(&LaserPointerMode::AddStationaryPoint, base::Unretained(this)),
true));
WmShell::Get()->AddPointerWatcher(this,
views::PointerWatcherEventTypes::DRAGS);
}
LaserPointerMode::~LaserPointerMode() {
OnDisable();
WmShell::Get()->RemovePointerWatcher(this);
}
LaserPointerMode::~LaserPointerMode() {}
PaletteGroup LaserPointerMode::GetGroup() const {
return PaletteGroup::MODE;
......@@ -56,16 +30,13 @@ PaletteToolId LaserPointerMode::GetToolId() const {
void LaserPointerMode::OnEnable() {
CommonPaletteTool::OnEnable();
WmShell::Get()->palette_delegate()->OnLaserPointerEnabled();
laser_pointer_view_->AddNewPoint(current_mouse_location_);
WmShell::Get()->SetLaserPointerEnabled(true);
}
void LaserPointerMode::OnDisable() {
CommonPaletteTool::OnDisable();
WmShell::Get()->palette_delegate()->OnLaserPointerDisabled();
StopTimer();
laser_pointer_view_->Stop();
WmShell::Get()->SetLaserPointerEnabled(false);
}
const gfx::VectorIcon& LaserPointerMode::GetActiveTrayIcon() const {
......@@ -80,37 +51,4 @@ views::View* LaserPointerMode::CreateView() {
return CreateDefaultView(
l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_LASER_POINTER_MODE));
}
void LaserPointerMode::StopTimer() {
timer_repeat_count_ = 0;
timer_->Stop();
}
void LaserPointerMode::AddStationaryPoint() {
laser_pointer_view_->AddNewPoint(current_mouse_location_);
// We can stop repeating the timer once the mouse has been stationary for
// longer than the life of a point.
if (timer_repeat_count_++ * kAddStationaryPointsDelayMs >=
kPointLifeDurationMs) {
StopTimer();
}
}
void LaserPointerMode::OnPointerEventObserved(
const ui::PointerEvent& event,
const gfx::Point& location_in_screen,
views::Widget* target) {
// TODO(sammiequon): Add support for pointer drags. See crbug.com/640410.
if (event.type() == ui::ET_POINTER_MOVED &&
event.pointer_details().pointer_type ==
ui::EventPointerType::POINTER_TYPE_PEN) {
current_mouse_location_ = location_in_screen;
if (enabled()) {
laser_pointer_view_->AddNewPoint(current_mouse_location_);
timer_repeat_count_ = 0;
if (!timer_->IsRunning())
timer_->Reset();
}
}
}
} // namespace ash
......@@ -7,8 +7,6 @@
#include "ash/ash_export.h"
#include "ash/common/system/chromeos/palette/common_palette_tool.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/pointer_watcher.h"
namespace base {
class Timer;
......@@ -16,19 +14,13 @@ class Timer;
namespace ash {
class LaserPointerView;
// Controller for the laser pointer functionality. Enables/disables laser
// pointer as well as receives points and passes them off to be rendered.
class ASH_EXPORT LaserPointerMode : public CommonPaletteTool,
public views::PointerWatcher {
// Controller for the laser pointer functionality.
class ASH_EXPORT LaserPointerMode : public CommonPaletteTool {
public:
explicit LaserPointerMode(Delegate* delegate);
~LaserPointerMode() override;
private:
friend class LaserPointerModeTestApi;
// PaletteTool:
PaletteGroup GetGroup() const override;
PaletteToolId GetToolId() const override;
......@@ -40,25 +32,6 @@ class ASH_EXPORT LaserPointerMode : public CommonPaletteTool,
// CommonPaletteTool:
const gfx::VectorIcon& GetPaletteIcon() const override;
// views::PointerWatcher:
void OnPointerEventObserved(const ui::PointerEvent& event,
const gfx::Point& location_in_screen,
views::Widget* target) override;
void StopTimer();
// Timer callback which adds a point where the mouse was last seen. This
// allows the trail to fade away when the mouse is stationary.
void AddStationaryPoint();
// Timer which will add a new stationary point when the mouse stops moving.
// This will remove points that are too old.
std::unique_ptr<base::Timer> timer_;
int timer_repeat_count_ = 0;
gfx::Point current_mouse_location_;
std::unique_ptr<LaserPointerView> laser_pointer_view_;
DISALLOW_COPY_AND_ASSIGN(LaserPointerMode);
};
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/common/system/chromeos/palette/tools/laser_pointer_mode_test_api.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_mode.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_points.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_view.h"
namespace ash {
LaserPointerModeTestApi::LaserPointerModeTestApi(
std::unique_ptr<LaserPointerMode> instance)
: instance_(std::move(instance)) {}
LaserPointerModeTestApi::~LaserPointerModeTestApi() {}
void LaserPointerModeTestApi::OnEnable() {
instance_->OnEnable();
}
void LaserPointerModeTestApi::OnDisable() {
instance_->OnDisable();
}
const LaserPointerPoints& LaserPointerModeTestApi::laser_points() {
return instance_->laser_pointer_view_->laser_points_;
}
const gfx::Point& LaserPointerModeTestApi::current_mouse_location() {
return instance_->current_mouse_location_;
}
} // namespace ash
......@@ -25,10 +25,6 @@ bool TestPaletteDelegate::HasNoteApp() {
return has_note_app_;
}
void TestPaletteDelegate::OnLaserPointerEnabled() {}
void TestPaletteDelegate::OnLaserPointerDisabled() {}
void TestPaletteDelegate::SetPartialMagnifierState(bool enabled) {
partial_magnifier_state_ = enabled;
}
......
......@@ -48,8 +48,6 @@ class TestPaletteDelegate : public PaletteDelegate {
const EnableListener& on_state_changed) override;
void CreateNote() override;
bool HasNoteApp() override;
void OnLaserPointerEnabled() override;
void OnLaserPointerDisabled() override;
void SetPartialMagnifierState(bool enabled) override;
void SetStylusStateChangedCallback(
const OnStylusStateChangedCallback& on_stylus_state_changed) override;
......
......@@ -389,6 +389,9 @@ class ASH_EXPORT WmShell {
// TODO(jamescook): Remove this when VirtualKeyboardController has been moved.
virtual void ToggleIgnoreExternalKeyboard() = 0;
// Enable or disable the laser pointer.
virtual void SetLaserPointerEnabled(bool enabled) = 0;
#endif
protected:
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/laser/laser_pointer_controller.h"
#include "ash/common/system/chromeos/palette/palette_utils.h"
#include "ash/laser/laser_pointer_view.h"
#include "ash/shell.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/display/screen.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
// A point gets removed from the collection if it is older than
// |kPointLifeDurationMs|.
const int kPointLifeDurationMs = 200;
// When no move events are being received we add a new point every
// |kAddStationaryPointsDelayMs| so that points older than
// |kPointLifeDurationMs| can get removed.
const int kAddStationaryPointsDelayMs = 5;
aura::Window* GetCurrentRootWindow() {
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
for (aura::Window* root_window : root_windows) {
if (root_window->ContainsPointInRoot(
root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot()))
return root_window;
}
return nullptr;
}
} // namespace
LaserPointerController::LaserPointerController()
: stationary_timer_(new base::Timer(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kAddStationaryPointsDelayMs),
base::Bind(&LaserPointerController::AddStationaryPoint,
base::Unretained(this)),
true /* is_repeating */)) {}
LaserPointerController::~LaserPointerController() {
Shell::GetInstance()->RemovePreTargetHandler(this);
}
void LaserPointerController::SetEnabled(bool enabled) {
if (enabled == enabled_)
return;
enabled_ = enabled;
if (enabled_) {
Shell::GetInstance()->AddPreTargetHandler(this);
} else {
laser_pointer_view_.reset();
Shell::GetInstance()->RemovePreTargetHandler(this);
}
}
void LaserPointerController::OnMouseEvent(ui::MouseEvent* event) {
if (!enabled_)
return;
if (event->pointer_details().pointer_type !=
ui::EventPointerType::POINTER_TYPE_PEN)
return;
if (event->type() != ui::ET_MOUSE_DRAGGED &&
event->type() != ui::ET_MOUSE_PRESSED &&
event->type() != ui::ET_MOUSE_RELEASED)
return;
// Delete the LaserPointerView instance if mouse is released.
if (event->type() == ui::ET_MOUSE_RELEASED) {
stationary_timer_->Stop();
laser_pointer_view_->Stop();
laser_pointer_view_.reset();
return;
}
// This will handle creating the initial laser pointer view on
// ET_MOUSE_PRESSED events.
SwitchTargetRootWindowIfNeeded(GetCurrentRootWindow());
if (laser_pointer_view_) {
// Remap point from where it was captured to the display it is actually on.
gfx::Point event_location = event->root_location();
aura::Window* target = static_cast<aura::Window*>(event->target());
aura::Window* event_root = target->GetRootWindow();
aura::Window::ConvertPointToTarget(
event_root, laser_pointer_view_->GetRootWindow(), &event_location);
current_mouse_location_ = event_location;
laser_pointer_view_->AddNewPoint(current_mouse_location_);
stationary_timer_repeat_count_ = 0;
if (event->type() == ui::ET_MOUSE_DRAGGED) {
// Start the timer to add stationary points if dragged.
if (!stationary_timer_->IsRunning())
stationary_timer_->Reset();
}
// If the stylus is over the palette icon or widget, do not consume the
// event.
if (!PaletteContainsPointInScreen(current_mouse_location_))
event->StopPropagation();
}
}
void LaserPointerController::OnWindowDestroying(aura::Window* window) {
SwitchTargetRootWindowIfNeeded(window);
}
void LaserPointerController::SwitchTargetRootWindowIfNeeded(
aura::Window* root_window) {
if (!root_window) {
stationary_timer_->Stop();
laser_pointer_view_.reset();
} else if (laser_pointer_view_) {
laser_pointer_view_->ReparentWidget(root_window);
} else if (enabled_) {
laser_pointer_view_.reset(new LaserPointerView(
base::TimeDelta::FromMilliseconds(kPointLifeDurationMs), root_window));
}
}
void LaserPointerController::AddStationaryPoint() {
laser_pointer_view_->AddNewPoint(current_mouse_location_);
// We can stop repeating the timer once the mouse has been stationary for
// longer than the life of a point.
if (stationary_timer_repeat_count_ * kAddStationaryPointsDelayMs >=
kPointLifeDurationMs) {
stationary_timer_->Stop();
}
stationary_timer_repeat_count_++;
}
} // namespace ash
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_LASER_LASER_POINTER_CONTROLLER_H_
#define ASH_LASER_LASER_POINTER_CONTROLLER_H_
#include <memory>
#include "ash/ash_export.h"
#include "base/macros.h"
#include "ui/aura/window_observer.h"
#include "ui/events/event_handler.h"
#include "ui/gfx/geometry/point.h"
namespace base {
class Timer;
}
namespace ui {
class MouseEvent;
}
namespace ash {
class LaserPointerView;
// Controller for the laser pointer functionality. Enables/disables laser
// pointer as well as receives points and passes them off to be rendered.
class ASH_EXPORT LaserPointerController : public ui::EventHandler,
public aura::WindowObserver {
public:
LaserPointerController();
~LaserPointerController() override;
// Turns the laser pointer feature on or off. The user still has to press and
// drag to see the laser pointer.
void SetEnabled(bool enabled);
private:
friend class LaserPointerControllerTestApi;
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* event) override;
// aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
// Reparent, recreate or destroy LaserPointerView instance as needed based on
// the current window and the widgets window.
void SwitchTargetRootWindowIfNeeded(aura::Window* root_window);
// Timer callback which adds a point where the mouse was last seen. This
// allows the trail to fade away when the mouse is stationary.
void AddStationaryPoint();
// Timer which will add a new stationary point when the mouse stops moving.
// This will remove points that are too old.
std::unique_ptr<base::Timer> stationary_timer_;
int stationary_timer_repeat_count_ = 0;
bool enabled_ = false;
// The last seen mouse location in screen coordinates.
gfx::Point current_mouse_location_;
// |laser_pointer_view_| will only hold an instance when the laser pointer is
// enabled and activated (pressed or dragged).
std::unique_ptr<LaserPointerView> laser_pointer_view_;
DISALLOW_COPY_AND_ASSIGN(LaserPointerController);
};
} // namespace ash
#endif // ASH_LASER_LASER_POINTER_CONTROLLER_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/laser/laser_pointer_controller_test_api.h"
#include "ash/laser/laser_pointer_controller.h"
#include "ash/laser/laser_pointer_points.h"
#include "ash/laser/laser_pointer_view.h"
namespace ash {
LaserPointerControllerTestApi::LaserPointerControllerTestApi(
LaserPointerController* instance)
: instance_(instance) {}
LaserPointerControllerTestApi::~LaserPointerControllerTestApi() {}
void LaserPointerControllerTestApi::SetEnabled(bool enabled) {
instance_->SetEnabled(enabled);
}
bool LaserPointerControllerTestApi::IsShowingLaserPointer() {
return instance_->laser_pointer_view_ != nullptr;
}
const LaserPointerPoints& LaserPointerControllerTestApi::laser_points() {
return instance_->laser_pointer_view_->laser_points_;
}
LaserPointerView* LaserPointerControllerTestApi::laser_pointer_view() {
return instance_->laser_pointer_view_.get();
}
} // namespace ash
......@@ -2,36 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_TESTAPI_H_
#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_TESTAPI_H_
#include <memory>
#ifndef ASH_LASER_LASER_POINTER_CONTROLLER_TEST_API_H_
#define ASH_LASER_LASER_POINTER_CONTROLLER_TEST_API_H_
#include "base/macros.h"
#include "ui/gfx/geometry/point.h"
namespace ash {
class LaserPointerMode;
class LaserPointerController;
class LaserPointerPoints;
class LaserPointerView;
// An api for testing the laser_pointer_mode class.
class LaserPointerModeTestApi {
// An api for testing the LaserPointerController class.
class LaserPointerControllerTestApi {
public:
LaserPointerModeTestApi(std::unique_ptr<LaserPointerMode> instance);
~LaserPointerModeTestApi();
explicit LaserPointerControllerTestApi(LaserPointerController* instance);
~LaserPointerControllerTestApi();
void OnEnable();
void OnDisable();
void SetEnabled(bool enabled);
bool IsShowingLaserPointer();
const LaserPointerPoints& laser_points();
const gfx::Point& current_mouse_location();
LaserPointerView* laser_pointer_view();
private:
std::unique_ptr<LaserPointerMode> instance_;
LaserPointerController* instance_;
DISALLOW_COPY_AND_ASSIGN(LaserPointerModeTestApi);
DISALLOW_COPY_AND_ASSIGN(LaserPointerControllerTestApi);
};
} // namespace ash
#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_MODE_TESTAPI_H_
#endif // ASH_LASER_LASER_POINTER_CONTROLLER_TEST_API_H_
......@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/common/system/chromeos/palette/tools/laser_pointer_mode.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_mode_test_api.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_points_test_api.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_view.h"
#include "ash/common/test/test_palette_delegate.h"
#include "ash/common/wm_shell.h"
#include "ash/laser/laser_pointer_controller.h"
#include "ash/laser/laser_pointer_controller_test_api.h"
#include "ash/laser/laser_pointer_points_test_api.h"
#include "ash/laser/laser_pointer_view.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ui/events/test/event_generator.h"
......@@ -16,57 +15,44 @@ namespace {
const int kTestPointsLifetimeSeconds = 5;
// TODO(sammiequon): Move this test into a different file. See
// http://crbug.com/646953.
class LaserPointerPointsTest : public test::AshTestBase {
public:
LaserPointerPointsTest()
: points_(base::TimeDelta::FromSeconds(kTestPointsLifetimeSeconds)),
points_test_api_(base::MakeUnique<LaserPointerPoints>(
base::TimeDelta::FromSeconds(kTestPointsLifetimeSeconds))) {}
: points_(base::TimeDelta::FromSeconds(kTestPointsLifetimeSeconds)) {}
~LaserPointerPointsTest() override {}
void SetUp() override {
AshTestBase::SetUp();
// Add a test delegate so that laser pointer mode does not complain when
// being destroyed.
WmShell::Get()->SetPaletteDelegateForTesting(
base::MakeUnique<TestPaletteDelegate>());
}
protected:
LaserPointerPoints points_;
LaserPointerPointsTestApi points_test_api_;
private:
DISALLOW_COPY_AND_ASSIGN(LaserPointerPointsTest);
};
class LaserPointerModeTest : public test::AshTestBase {
class LaserPointerControllerTest : public test::AshTestBase {
public:
LaserPointerModeTest() {}
~LaserPointerModeTest() override {}
LaserPointerControllerTest() {}
~LaserPointerControllerTest() override {}
void SetUp() override {
AshTestBase::SetUp();
WmShell::Get()->SetPaletteDelegateForTesting(
base::MakeUnique<TestPaletteDelegate>());
mode_test_api_.reset(new LaserPointerModeTestApi(
base::WrapUnique<LaserPointerMode>(new LaserPointerMode(nullptr))));
controller_.reset(new LaserPointerController());
}
void TearDown() override {
// This needs to be called first to remove the pointer watcher otherwise
// tear down will complain about there being more than zero pointer watcher
// alive.
mode_test_api_.reset();
// This needs to be called first to remove the event handler before the
// shell instance gets torn down.
controller_.reset();
AshTestBase::TearDown();
}
protected:
std::unique_ptr<LaserPointerModeTestApi> mode_test_api_;
std::unique_ptr<LaserPointerController> controller_;
private:
DISALLOW_COPY_AND_ASSIGN(LaserPointerModeTest);
DISALLOW_COPY_AND_ASSIGN(LaserPointerControllerTest);
};
} // namespace
......@@ -122,6 +108,8 @@ TEST_F(LaserPointerPointsTest, LaserPointerInternalCollection) {
// Test the laser pointer points collection to verify that old points are
// removed.
TEST_F(LaserPointerPointsTest, LaserPointerInternalCollectionDeletion) {
LaserPointerPointsTestApi points_test_api_(&points_);
// When a point older than kTestPointsLifetime (5 seconds) is added, it
// should get removed.
points_test_api_.MoveForwardInTime(base::TimeDelta::FromSeconds(1));
......@@ -148,45 +136,71 @@ TEST_F(LaserPointerPointsTest, LaserPointerInternalCollectionDeletion) {
}
// Test to ensure the class responsible for drawing the laser pointer receives
// points from mouse movements as expected.
TEST_F(LaserPointerModeTest, LaserPointerRenderer) {
// points from stylus movements as expected.
TEST_F(LaserPointerControllerTest, LaserPointerRenderer) {
LaserPointerControllerTestApi controller_test_api_(controller_.get());
// The laser pointer mode only works with stylus.
GetEventGenerator().EnterPenPointerMode();
GetEventGenerator().MoveMouseToInHost(gfx::Point(10, 40));
EXPECT_EQ(0, mode_test_api_->laser_points().GetNumberOfPoints());
// Verify enabling the mode will start with a single point at the current
// location.
mode_test_api_->OnEnable();
EXPECT_EQ(1, mode_test_api_->laser_points().GetNumberOfPoints());
// Verify moving the mouse 4 times will add 4 more points.
GetEventGenerator().MoveMouseToInHost(gfx::Point(25, 66));
GetEventGenerator().MoveMouseToInHost(gfx::Point(91, 38));
GetEventGenerator().MoveMouseToInHost(gfx::Point(34, 58));
GetEventGenerator().MoveMouseToInHost(gfx::Point(19, 71));
EXPECT_EQ(5, mode_test_api_->laser_points().GetNumberOfPoints());
// Verify disabling the mode will clear any active points.
mode_test_api_->OnDisable();
EXPECT_EQ(0, mode_test_api_->laser_points().GetNumberOfPoints());
// When disabled the laser pointer should not be showing.
GetEventGenerator().MoveMouseToInHost(gfx::Point(1, 1));
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify that by enabling the mode, the laser pointer should still not be
// showing.
controller_test_api_.SetEnabled(true);
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify moving the stylus 4 times will not display the laser pointer.
GetEventGenerator().MoveMouseToInHost(gfx::Point(2, 2));
GetEventGenerator().MoveMouseToInHost(gfx::Point(3, 3));
GetEventGenerator().MoveMouseToInHost(gfx::Point(4, 4));
GetEventGenerator().MoveMouseToInHost(gfx::Point(5, 5));
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify pressing the stylus will show the laser pointer and add a point.
GetEventGenerator().PressLeftButton();
EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer());
EXPECT_EQ(1, controller_test_api_.laser_points().GetNumberOfPoints());
// Verify dragging the stylus 2 times will add 2 more points.
GetEventGenerator().MoveMouseToInHost(gfx::Point(6, 6));
GetEventGenerator().MoveMouseToInHost(gfx::Point(7, 7));
EXPECT_EQ(3, controller_test_api_.laser_points().GetNumberOfPoints());
// Verify releasing the stylus hides the laser pointer.
GetEventGenerator().ReleaseLeftButton();
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify that disabling the mode does not display the laser pointer.
controller_test_api_.SetEnabled(false);
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify that disabling the mode while laser pointer is displayed does not
// display the laser pointer.
controller_test_api_.SetEnabled(true);
GetEventGenerator().PressLeftButton();
GetEventGenerator().MoveMouseToInHost(gfx::Point(6, 6));
EXPECT_TRUE(controller_test_api_.IsShowingLaserPointer());
controller_test_api_.SetEnabled(false);
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify that the laser pointer does not add points while disabled.
GetEventGenerator().MoveMouseToInHost(gfx::Point(34, 58));
GetEventGenerator().MoveMouseToInHost(gfx::Point(19, 71));
EXPECT_EQ(0, mode_test_api_->laser_points().GetNumberOfPoints());
// Verify that the laser pointer adds the last seen stylus point when enabled
// even when stylus mode is disabled.
GetEventGenerator().PressLeftButton();
GetEventGenerator().MoveMouseToInHost(gfx::Point(8, 8));
GetEventGenerator().ReleaseLeftButton();
GetEventGenerator().MoveMouseToInHost(gfx::Point(9, 9));
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
// Verify that the laser pointer does not get shown if points are not coming
// from the stylus, even when enabled.
GetEventGenerator().ExitPenPointerMode();
mode_test_api_->OnEnable();
EXPECT_EQ(1, mode_test_api_->laser_points().GetNumberOfPoints());
EXPECT_EQ(GetEventGenerator().current_location(),
mode_test_api_->laser_points().GetNewest().location);
// Verify that the laser pointer does not add additional points when move
// events are not from stylus.
GetEventGenerator().MoveMouseToInHost(gfx::Point(34, 58));
GetEventGenerator().MoveMouseToInHost(gfx::Point(19, 71));
EXPECT_EQ(1, mode_test_api_->laser_points().GetNumberOfPoints());
controller_test_api_.SetEnabled(true);
GetEventGenerator().PressLeftButton();
GetEventGenerator().MoveMouseToInHost(gfx::Point(10, 10));
GetEventGenerator().MoveMouseToInHost(gfx::Point(11, 11));
EXPECT_FALSE(controller_test_api_.IsShowingLaserPointer());
GetEventGenerator().ReleaseLeftButton();
}
} // namespace ash
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/common/system/chromeos/palette/tools/laser_pointer_points.h"
#include "ash/laser/laser_pointer_points.h"
#include <algorithm>
#include <limits>
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_
#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_
#ifndef ASH_LASER_LASER_POINTER_POINTS_H_
#define ASH_LASER_LASER_POINTER_POINTS_H_
#include <deque>
#include <memory>
......@@ -61,4 +61,4 @@ class ASH_EXPORT LaserPointerPoints {
} // namespace ash
#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_H_
#endif // ASH_LASER_LASER_POINTER_POINTS_H_
......@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/common/system/chromeos/palette/tools/laser_pointer_points_test_api.h"
#include "ash/laser/laser_pointer_points_test_api.h"
#include "ash/common/system/chromeos/palette/tools/laser_pointer_points.h"
#include "ash/laser/laser_pointer_points.h"
namespace ash {
LaserPointerPointsTestApi::LaserPointerPointsTestApi(
std::unique_ptr<LaserPointerPoints> instance)
: new_point_time_(base::Time::Now()), instance_(std::move(instance)) {}
LaserPointerPoints* instance)
: new_point_time_(base::Time::Now()), instance_(instance) {}
LaserPointerPointsTestApi::~LaserPointerPointsTestApi() {}
......
......@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_TESTAPI_H_
#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_TESTAPI_H_
#include <memory>
#ifndef ASH_LASER_LASER_POINTER_POINTS_TEST_API_H_
#define ASH_LASER_LASER_POINTER_POINTS_TEST_API_H_
#include "base/time/time.h"
......@@ -16,7 +14,7 @@ class LaserPointerPoints;
// An api for testing the laser_pointer_points class.
class LaserPointerPointsTestApi {
public:
LaserPointerPointsTestApi(std::unique_ptr<LaserPointerPoints> instance);
LaserPointerPointsTestApi(LaserPointerPoints* instance);
~LaserPointerPointsTestApi();
int GetNumberOfPoints() const;
......@@ -27,10 +25,10 @@ class LaserPointerPointsTestApi {
private:
// The time the new points are added.
base::Time new_point_time_;
std::unique_ptr<LaserPointerPoints> instance_;
LaserPointerPoints* instance_;
DISALLOW_COPY_AND_ASSIGN(LaserPointerPointsTestApi);
};
} // namespace ash
#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_POINTS_TESTAPI_H_
#endif // ASH_LASER_LASER_POINTER_POINTS_TEST_API_H_
......@@ -2,21 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/common/system/chromeos/palette/tools/laser_pointer_view.h"
#include "ash/laser/laser_pointer_view.h"
#include <memory>
#include "ash/common/shell_window_ids.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
#include "ash/laser/laser_pointer_points.h"
#include "ash/shell.h"
#include "base/timer/timer.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
// Variables for rendering the laser. Radius in DIP.
const double kPointInitialRadius = 5;
const double kPointFinalRadius = 0.25;
const int kPointInitialOpacity = 200;
......@@ -39,7 +43,8 @@ double LinearInterpolate(double initial_value,
////////////////////////////////////////////////////////////////////////////////
// LaserPointerView
LaserPointerView::LaserPointerView(base::TimeDelta life_duration)
LaserPointerView::LaserPointerView(base::TimeDelta life_duration,
aura::Window* root_window)
: laser_points_(life_duration) {
widget_.reset(new views::Widget);
views::Widget::InitParams params;
......@@ -49,11 +54,9 @@ LaserPointerView::LaserPointerView(base::TimeDelta life_duration)
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
WmShell::Get()
->GetRootWindowForNewWindows()
->GetRootWindowController()
->ConfigureWidgetInitParamsForContainer(
widget_.get(), kShellWindowId_OverlayContainer, &params);
params.parent =
Shell::GetContainer(root_window, kShellWindowId_OverlayContainer);
widget_->Init(params);
widget_->Show();
widget_->SetContentsView(this);
......@@ -67,13 +70,34 @@ void LaserPointerView::Stop() {
SchedulePaint();
}
aura::Window* LaserPointerView::GetRootWindow() {
return widget_->GetNativeView()->GetRootWindow();
}
void LaserPointerView::ReparentWidget(aura::Window* new_root_window) {
if (GetRootWindow() != new_root_window) {
// TODO(sammiequon): Investigate if we should stop (which removes all
// points) or keep the old points. See http://crbug.com/647793.
Stop();
views::Widget::ReparentNativeView(
widget_->GetNativeView(),
Shell::GetContainer(new_root_window, kShellWindowId_OverlayContainer));
}
}
void LaserPointerView::AddNewPoint(const gfx::Point& new_point) {
laser_points_.AddPoint(new_point);
// The bounding box should be relative to the screen.
gfx::Point screen_offset =
widget_->GetNativeView()->GetRootWindow()->GetBoundsInScreen().origin();
// Expand the bounding box so that it includes the radius of the points on the
// edges.
gfx::Rect bounding_box;
bounding_box = laser_points_.GetBoundingBox();
bounding_box.Offset(-kPointInitialRadius, -kPointInitialRadius);
bounding_box.Offset(screen_offset.x(), screen_offset.y());
bounding_box.set_width(bounding_box.width() + (kPointInitialRadius * 2));
bounding_box.set_height(bounding_box.height() + (kPointInitialRadius * 2));
widget_->SetBounds(bounding_box);
......@@ -93,7 +117,10 @@ void LaserPointerView::OnPaint(gfx::Canvas* canvas) {
base::Time newest = laser_points_.GetNewest().creation_time;
gfx::Point previous_point = laser_points_.GetOldest().location;
gfx::Point current_point;
gfx::Rect widget_bounds = widget_->GetWindowBoundsInScreen();
// Compute the offset of the current widget.
gfx::Point widget_offset =
widget_->GetNativeView()->GetBoundsInRootWindow().origin();
int num_points_ = laser_points_.GetNumberOfPoints();
int point_count = 0;
for (const LaserPointerPoints::LaserPoint& point :
......@@ -110,7 +137,7 @@ void LaserPointerView::OnPaint(gfx::Canvas* canvas) {
double radius = LinearInterpolate(kPointInitialRadius, kPointFinalRadius,
relative_time);
gfx::Vector2d center = point.location - widget_bounds.origin();
gfx::Vector2d center = point.location - widget_offset;
current_point = gfx::Point(center.x(), center.y());
// If we draw laser_points_ that are within a stroke width of each other,
......@@ -132,6 +159,7 @@ void LaserPointerView::OnPaint(gfx::Canvas* canvas) {
canvas->DrawLine(previous_point, current_point, paint);
previous_point = current_point;
}
// Draw the last point as a circle.
paint.setColor(SkColorSetA(kPointColor, kPointInitialOpacity));
paint.setStyle(SkPaint::kFill_Style);
canvas->DrawCircle(current_point, kPointInitialRadius, paint);
......
......@@ -2,15 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_VIEW_H_
#define ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_VIEW_H_
#ifndef ASH_LASER_LASER_POINTER_VIEW_H_
#define ASH_LASER_LASER_POINTER_VIEW_H_
#include <memory>
#include "ash/common/system/chromeos/palette/tools/laser_pointer_points.h"
#include "ash/laser/laser_pointer_points.h"
#include "base/macros.h"
#include "ui/views/view.h"
namespace aura {
class Window;
}
namespace gfx {
class Point;
}
......@@ -26,14 +30,18 @@ namespace ash {
// trail of lines to help users track.
class LaserPointerView : public views::View {
public:
explicit LaserPointerView(base::TimeDelta life_duration);
LaserPointerView(base::TimeDelta life_duration, aura::Window* root_window);
~LaserPointerView() override;
void AddNewPoint(const gfx::Point& new_point);
void Stop();
aura::Window* GetRootWindow();
// Reparents the widget if needed.
void ReparentWidget(aura::Window* new_root_window);
private:
friend class LaserPointerModeTestApi;
friend class LaserPointerControllerTestApi;
// view::View:
void OnPaint(gfx::Canvas* canvas) override;
......@@ -46,4 +54,4 @@ class LaserPointerView : public views::View {
} // namespace ash
#endif // ASH_COMMON_SYSTEM_CHROMEOS_PALETTE_TOOLS_LASER_POINTER_VIEW_H_
#endif // ASH_LASER_LASER_POINTER_VIEW_H_
......@@ -4,6 +4,7 @@
#include "ash/magnifier/partial_magnification_controller.h"
#include "ash/common/system/chromeos/palette/palette_utils.h"
#include "ash/shell.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
......@@ -14,10 +15,6 @@
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"
#if defined(OS_CHROMEOS)
#include "ash/common/system/chromeos/palette/palette_utils.h"
#endif
namespace ash {
namespace {
......@@ -64,16 +61,6 @@ aura::Window* GetCurrentRootWindow() {
return nullptr;
}
// Returns true if the event should be processed normally, ie, the stylus is
// over the palette icon or widget.
bool ShouldSkipEventFiltering(const gfx::Point& point) {
#if defined(OS_CHROMEOS)
return PaletteContainsPointInScreen(point);
#else
return false;
#endif
}
} // namespace
// The content mask provides a clipping layer for the magnification window so we
......@@ -254,8 +241,9 @@ void PartialMagnificationController::OnLocatedEvent(
gfx::Point screen_point = event->root_location();
wm::ConvertPointToScreen(event_root, &screen_point);
// If the stylus is pressed on the palette icon or widget, do not activate.
if (event->type() == ui::ET_MOUSE_PRESSED &&
!ShouldSkipEventFiltering(screen_point)) {
!PaletteContainsPointInScreen(screen_point)) {
SetActive(true);
}
......@@ -282,7 +270,8 @@ void PartialMagnificationController::OnLocatedEvent(
event_root, host_widget_->GetNativeView()->GetRootWindow(), &point);
host_widget_->SetBounds(GetBounds(point));
if (!ShouldSkipEventFiltering(screen_point))
// If the stylus is over the palette icon or widget, do not consume the event.
if (!PaletteContainsPointInScreen(screen_point))
event->StopPropagation();
}
......
......@@ -414,6 +414,10 @@ bool WmShellMus::IsTouchDown() {
void WmShellMus::ToggleIgnoreExternalKeyboard() {
NOTIMPLEMENTED();
}
void WmShellMus::SetLaserPointerEnabled(bool enabled) {
NOTIMPLEMENTED();
}
#endif // defined(OS_CHROMEOS)
ui::WindowTreeClient* WmShellMus::window_tree_client() {
......
......@@ -114,6 +114,7 @@ class WmShellMus : public WmShell, public ui::WindowTreeClientObserver {
bool IsTouchDown() override;
#if defined(OS_CHROMEOS)
void ToggleIgnoreExternalKeyboard() override;
void SetLaserPointerEnabled(bool enabled) override;
#endif
private:
......
......@@ -53,6 +53,7 @@
#include "ash/high_contrast/high_contrast_controller.h"
#include "ash/host/ash_window_tree_host_init_params.h"
#include "ash/ime/input_method_event_handler.h"
#include "ash/laser/laser_pointer_controller.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/magnifier/partial_magnification_controller.h"
#include "ash/root_window_controller.h"
......@@ -539,7 +540,6 @@ Shell::~Shell() {
// delete them before invalidating the instance.
// Alphabetical. TODO(oshima): sort.
magnification_controller_.reset();
partial_magnification_controller_.reset();
tooltip_controller_.reset();
event_client_.reset();
toplevel_window_event_handler_.reset();
......@@ -561,6 +561,8 @@ Shell::~Shell() {
touch_transformer_controller_.reset();
stylus_metrics_recorder_.reset();
audio_a11y_controller_.reset();
laser_pointer_controller_.reset();
partial_magnification_controller_.reset();
#endif // defined(OS_CHROMEOS)
// This also deletes all RootWindows. Note that we invoke Shutdown() on
......@@ -783,11 +785,14 @@ void Shell::Init(const ShellInitParams& init_params) {
// RootWindowController as possible.
visibility_controller_.reset(new AshVisibilityController);
#if defined(OS_CHROMEOS)
laser_pointer_controller_.reset(new LaserPointerController());
partial_magnification_controller_.reset(new PartialMagnificationController());
#endif
magnification_controller_.reset(MagnificationController::CreateInstance());
wm_shell_->CreateMruWindowTracker();
partial_magnification_controller_.reset(new PartialMagnificationController());
autoclick_controller_.reset(AutoclickController::CreateInstance());
high_contrast_controller_.reset(new HighContrastController);
......
......@@ -85,6 +85,7 @@ class FirstRunHelper;
class GPUSupport;
class HighContrastController;
class ImmersiveHandlerFactoryAsh;
class LaserPointerController;
class LinkHandlerModelFactory;
class LocaleNotificationController;
class LockStateController;
......@@ -280,6 +281,12 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
TouchTransformerController* touch_transformer_controller() {
return touch_transformer_controller_.get();
}
LaserPointerController* laser_pointer_controller() {
return laser_pointer_controller_.get();
}
PartialMagnificationController* partial_magnification_controller() {
return partial_magnification_controller_.get();
}
#endif // defined(OS_CHROMEOS)
ScreenshotController* screenshot_controller() {
return screenshot_controller_.get();
......@@ -304,10 +311,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
return magnification_controller_.get();
}
PartialMagnificationController* partial_magnification_controller() {
return partial_magnification_controller_.get();
}
AutoclickController* autoclick_controller() {
return autoclick_controller_.get();
}
......@@ -472,8 +475,6 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
std::unique_ptr<WindowTreeHostManager> window_tree_host_manager_;
std::unique_ptr<HighContrastController> high_contrast_controller_;
std::unique_ptr<MagnificationController> magnification_controller_;
std::unique_ptr<PartialMagnificationController>
partial_magnification_controller_;
std::unique_ptr<AutoclickController> autoclick_controller_;
std::unique_ptr<aura::client::FocusClient> focus_client_;
......@@ -536,6 +537,10 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
std::unique_ptr<ui::EventHandler> magnifier_key_scroll_handler_;
std::unique_ptr<ui::EventHandler> speech_feedback_handler_;
std::unique_ptr<StylusMetricsRecorder> stylus_metrics_recorder_;
std::unique_ptr<LaserPointerController> laser_pointer_controller_;
std::unique_ptr<PartialMagnificationController>
partial_magnification_controller_;
#endif // defined(OS_CHROMEOS)
// |native_cursor_manager_| is owned by |cursor_manager_|, but we keep a
......
......@@ -92,8 +92,6 @@ class PaletteDelegateImpl : public PaletteDelegate {
}
void CreateNote() override {}
bool HasNoteApp() override { return false; }
void OnLaserPointerEnabled() override {}
void OnLaserPointerDisabled() override {}
void SetPartialMagnifierState(bool enabled) override {}
void SetStylusStateChangedCallback(
const OnStylusStateChangedCallback& on_stylus_state_changed) override {}
......
......@@ -222,16 +222,4 @@ void PaletteDelegateChromeOS::CancelPartialScreenshot() {
void PaletteDelegateChromeOS::OnStylusStateChanged(ui::StylusState state) {
on_stylus_state_changed_.Run(state);
}
void PaletteDelegateChromeOS::OnLaserPointerEnabled() {
// We lock the cursor after we hide it because compound_event_filter.cc will
// attempt to call ShowCursor every time it recieves a mouse event.
ash::Shell::GetInstance()->cursor_manager()->HideCursor();
ash::Shell::GetInstance()->cursor_manager()->LockCursor();
}
void PaletteDelegateChromeOS::OnLaserPointerDisabled() {
ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
ash::Shell::GetInstance()->cursor_manager()->ShowCursor();
}
} // namespace chromeos
......@@ -38,9 +38,6 @@ class PaletteDelegateChromeOS : public ash::PaletteDelegate,
~PaletteDelegateChromeOS() override;
void OnLaserPointerEnabled() override;
void OnLaserPointerDisabled() override;
private:
PaletteDelegateChromeOS();
......
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