Commit 55f0eaf2 authored by kylechar's avatar kylechar Committed by Commit bot

Move TouchTransformerController to ui/display/.

We need to add touchscreen support to mustash where display and
input-device management happens in a different process from ash.
Decouple ash::TouchTransformerController from the rest of ash and move
to src/ui/display/ so it can be used with mus. This also decouples and
moves the accompanying tests.

The dependency on WindowTreeHostManager can't be broken so add
AshTouchTransformController which extends TouchTransformController and
listens for ash display configuration changes.

BUG=679747

Review-Url: https://codereview.chromium.org/2617043003
Cr-Commit-Position: refs/heads/master@{#443037}
parent 33b63eb4
...@@ -751,14 +751,14 @@ component("ash") { ...@@ -751,14 +751,14 @@ component("ash") {
"system/chromeos/rotation/tray_rotation_lock.h", "system/chromeos/rotation/tray_rotation_lock.h",
"system/chromeos/screen_layout_observer.cc", "system/chromeos/screen_layout_observer.cc",
"system/chromeos/screen_layout_observer.h", "system/chromeos/screen_layout_observer.h",
"touch/ash_touch_transform_controller.cc",
"touch/ash_touch_transform_controller.h",
"touch/touch_hud_debug.cc", "touch/touch_hud_debug.cc",
"touch/touch_hud_debug.h", "touch/touch_hud_debug.h",
"touch/touch_hud_projection.cc", "touch/touch_hud_projection.cc",
"touch/touch_hud_projection.h", "touch/touch_hud_projection.h",
"touch/touch_observer_hud.cc", "touch/touch_observer_hud.cc",
"touch/touch_observer_hud.h", "touch/touch_observer_hud.h",
"touch/touch_transformer_controller.cc",
"touch/touch_transformer_controller.h",
"touch/touch_uma.cc", "touch/touch_uma.cc",
"touch/touch_uma.h", "touch/touch_uma.h",
"utility/screenshot_controller.cc", "utility/screenshot_controller.cc",
...@@ -1281,7 +1281,6 @@ test("ash_unittests") { ...@@ -1281,7 +1281,6 @@ test("ash_unittests") {
"test/ash_unittests.cc", "test/ash_unittests.cc",
"tooltips/tooltip_controller_unittest.cc", "tooltips/tooltip_controller_unittest.cc",
"touch/touch_observer_hud_unittest.cc", "touch/touch_observer_hud_unittest.cc",
"touch/touch_transformer_controller_unittest.cc",
"utility/screenshot_controller_unittest.cc", "utility/screenshot_controller_unittest.cc",
"virtual_keyboard_controller_unittest.cc", "virtual_keyboard_controller_unittest.cc",
"wm/always_on_top_controller_unittest.cc", "wm/always_on_top_controller_unittest.cc",
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
#include "ash/system/chromeos/power/power_event_observer.h" #include "ash/system/chromeos/power/power_event_observer.h"
#include "ash/system/chromeos/power/video_activity_notifier.h" #include "ash/system/chromeos/power/video_activity_notifier.h"
#include "ash/system/chromeos/screen_layout_observer.h" #include "ash/system/chromeos/screen_layout_observer.h"
#include "ash/touch/touch_transformer_controller.h" #include "ash/touch/ash_touch_transform_controller.h"
#include "ash/utility/screenshot_controller.h" #include "ash/utility/screenshot_controller.h"
#include "ash/virtual_keyboard_controller.h" #include "ash/virtual_keyboard_controller.h"
#include "ash/wm/ash_focus_rules.h" #include "ash/wm/ash_focus_rules.h"
...@@ -743,11 +743,12 @@ void Shell::Init(const ShellInitParams& init_params) { ...@@ -743,11 +743,12 @@ void Shell::Init(const ShellInitParams& init_params) {
wm_shell_->SetSystemTrayDelegate( wm_shell_->SetSystemTrayDelegate(
base::WrapUnique(wm_shell_->delegate()->CreateSystemTrayDelegate())); base::WrapUnique(wm_shell_->delegate()->CreateSystemTrayDelegate()));
// Create TouchTransformerController before // Create AshTouchTransformController before
// WindowTreeHostManager::InitDisplays() // WindowTreeHostManager::InitDisplays()
// since TouchTransformerController listens on // since AshTouchTransformController listens on
// WindowTreeHostManager::Observer::OnDisplaysInitialized(). // WindowTreeHostManager::Observer::OnDisplaysInitialized().
touch_transformer_controller_.reset(new TouchTransformerController()); touch_transformer_controller_.reset(new AshTouchTransformController(
display_configurator_.get(), display_manager_.get()));
wm_shell_->SetKeyboardUI(KeyboardUI::Create()); wm_shell_->SetKeyboardUI(KeyboardUI::Create());
......
...@@ -112,7 +112,7 @@ class SystemGestureEventFilter; ...@@ -112,7 +112,7 @@ class SystemGestureEventFilter;
class SystemModalContainerEventFilter; class SystemModalContainerEventFilter;
class SystemTray; class SystemTray;
class ToplevelWindowEventHandler; class ToplevelWindowEventHandler;
class TouchTransformerController; class AshTouchTransformController;
class ScreenLayoutObserver; class ScreenLayoutObserver;
class VirtualKeyboardController; class VirtualKeyboardController;
class VideoActivityNotifier; class VideoActivityNotifier;
...@@ -268,7 +268,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, ...@@ -268,7 +268,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
PowerEventObserver* power_event_observer() { PowerEventObserver* power_event_observer() {
return power_event_observer_.get(); return power_event_observer_.get();
} }
TouchTransformerController* touch_transformer_controller() { AshTouchTransformController* touch_transformer_controller() {
return touch_transformer_controller_.get(); return touch_transformer_controller_.get();
} }
LaserPointerController* laser_pointer_controller() { LaserPointerController* laser_pointer_controller() {
...@@ -516,7 +516,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, ...@@ -516,7 +516,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate,
std::unique_ptr<ScreenOrientationController> screen_orientation_controller_; std::unique_ptr<ScreenOrientationController> screen_orientation_controller_;
std::unique_ptr<ScreenLayoutObserver> screen_layout_observer_; std::unique_ptr<ScreenLayoutObserver> screen_layout_observer_;
std::unique_ptr<TouchTransformerController> touch_transformer_controller_; std::unique_ptr<AshTouchTransformController> touch_transformer_controller_;
std::unique_ptr<ui::EventHandler> magnifier_key_scroll_handler_; std::unique_ptr<ui::EventHandler> magnifier_key_scroll_handler_;
std::unique_ptr<ui::EventHandler> speech_feedback_handler_; std::unique_ptr<ui::EventHandler> speech_feedback_handler_;
......
// Copyright 2017 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/touch/ash_touch_transform_controller.h"
#include "ash/shell.h"
#include "ui/display/manager/display_manager.h"
namespace ash {
AshTouchTransformController::AshTouchTransformController(
display::DisplayConfigurator* display_configurator,
display::DisplayManager* display_manager)
: TouchTransformController(display_configurator, display_manager) {
Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
}
AshTouchTransformController::~AshTouchTransformController() {
Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
}
void AshTouchTransformController::OnDisplaysInitialized() {
UpdateTouchTransforms();
}
void AshTouchTransformController::OnDisplayConfigurationChanged() {
UpdateTouchTransforms();
}
} // namespace ash
// Copyright 2017 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_TOUCH_ASH_TOUCH_TRANSFORM_CONTROLLER_H_
#define ASH_TOUCH_ASH_TOUCH_TRANSFORM_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "base/macros.h"
#include "ui/display/manager/chromeos/touch_transform_controller.h"
namespace display {
class DisplayConfigurator;
class DisplayManager;
}
namespace ash {
// AshTouchTransformController listens for display configuration changes and
// updates the touch transforms when one occurs.
class ASH_EXPORT AshTouchTransformController
: public display::TouchTransformController,
public WindowTreeHostManager::Observer {
public:
AshTouchTransformController(
display::DisplayConfigurator* display_configurator,
display::DisplayManager* display_manager);
~AshTouchTransformController() override;
// WindowTreeHostManager::Observer:
void OnDisplaysInitialized() override;
void OnDisplayConfigurationChanged() override;
private:
DISALLOW_COPY_AND_ASSIGN(AshTouchTransformController);
};
} // namespace ash
#endif // ASH_TOUCH_ASH_TOUCH_TRANSFORM_CONTROLLER_H_
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.h" #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/touch/touch_transformer_controller.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.h" #include "chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
...@@ -53,7 +52,7 @@ void TouchCalibratorController::StartCalibration( ...@@ -53,7 +52,7 @@ void TouchCalibratorController::StartCalibration(
base::MakeUnique<TouchCalibratorView>(display, is_primary_view); base::MakeUnique<TouchCalibratorView>(display, is_primary_view);
} }
// TODO(malaykeshav): Call TouchTransformerController::SetForCalibration() // TODO(malaykeshav): Call TouchTransformController::SetForCalibration()
// Add self as an event handler target. // Add self as an event handler target.
ash::Shell::GetInstance()->AddPreTargetHandler(this); ash::Shell::GetInstance()->AddPreTargetHandler(this);
...@@ -65,7 +64,7 @@ void TouchCalibratorController::StopCalibration() { ...@@ -65,7 +64,7 @@ void TouchCalibratorController::StopCalibration() {
is_calibrating_ = false; is_calibrating_ = false;
ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); ash::Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
// TODO(malaykeshav): Call TouchTransformerController::SetForCalibration() // TODO(malaykeshav): Call TouchTransformController::SetForCalibration()
// Remove self as the event handler. // Remove self as the event handler.
ash::Shell::GetInstance()->RemovePreTargetHandler(this); ash::Shell::GetInstance()->RemovePreTargetHandler(this);
......
...@@ -142,6 +142,7 @@ test("display_unittests") { ...@@ -142,6 +142,7 @@ test("display_unittests") {
"manager/chromeos/display_change_observer_unittest.cc", "manager/chromeos/display_change_observer_unittest.cc",
"manager/chromeos/display_configurator_unittest.cc", "manager/chromeos/display_configurator_unittest.cc",
"manager/chromeos/query_content_protection_task_unittest.cc", "manager/chromeos/query_content_protection_task_unittest.cc",
"manager/chromeos/touch_transform_controller_unittest.cc",
"manager/chromeos/touchscreen_util_unittest.cc", "manager/chromeos/touchscreen_util_unittest.cc",
"manager/chromeos/update_display_configuration_task_unittest.cc", "manager/chromeos/update_display_configuration_task_unittest.cc",
"manager/display_manager_utilities_unittest.cc", "manager/display_manager_utilities_unittest.cc",
......
...@@ -21,6 +21,8 @@ component("manager") { ...@@ -21,6 +21,8 @@ component("manager") {
"chromeos/display_util.h", "chromeos/display_util.h",
"chromeos/query_content_protection_task.cc", "chromeos/query_content_protection_task.cc",
"chromeos/query_content_protection_task.h", "chromeos/query_content_protection_task.h",
"chromeos/touch_transform_controller.cc",
"chromeos/touch_transform_controller.h",
"chromeos/touchscreen_util.cc", "chromeos/touchscreen_util.cc",
"chromeos/touchscreen_util.h", "chromeos/touchscreen_util.h",
"chromeos/update_display_configuration_task.cc", "chromeos/update_display_configuration_task.cc",
......
specific_include_rules = {
"touch_transform_controller.cc": [
"+third_party/skia",
],
}
...@@ -2,41 +2,44 @@ ...@@ -2,41 +2,44 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_ #ifndef UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_
#define ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_ #define UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_
#include <stdint.h>
#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/display/manager/display_manager_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/transform.h" #include "ui/gfx/transform.h"
namespace ui { namespace ui {
struct TouchscreenDevice; struct TouchscreenDevice;
} // namespace ui }
namespace ash { namespace display {
// TouchTransformerController listens to display configuration change class DisplayConfigurator;
// and updates the touch transformation for touch displays. class DisplayManager;
class ASH_EXPORT TouchTransformerController class ManagedDisplayInfo;
: public WindowTreeHostManager::Observer {
public:
TouchTransformerController();
~TouchTransformerController() override;
// Updates the TouchTransformer for touch device and pushes the new namespace test {
// TouchTransformer into device manager. class TouchTransformControllerTest;
void UpdateTouchTransformer() const; }
// WindowTreeHostManager::Observer: // TouchTransformController matches touchscreen displays with touch
void OnDisplaysInitialized() override; // input-devices and computes the coordinate transforms between display space
void OnDisplayConfigurationChanged() override; // and input-device space.
class DISPLAY_MANAGER_EXPORT TouchTransformController {
public:
TouchTransformController(DisplayConfigurator* display_configurator,
DisplayManager* display_manager);
~TouchTransformController();
// Updates the transform for touch input-devices and pushes the new transforms
// into device manager.
void UpdateTouchTransforms() const;
private: private:
friend class TouchTransformerControllerTest; friend class test::TouchTransformControllerTest;
// Returns a transform that will be used to change an event's location from // Returns a transform that will be used to change an event's location from
// the touchscreen's coordinate system into |display|'s coordinate system. // the touchscreen's coordinate system into |display|'s coordinate system.
...@@ -47,21 +50,20 @@ class ASH_EXPORT TouchTransformerController ...@@ -47,21 +50,20 @@ class ASH_EXPORT TouchTransformerController
// |framebuffer_size| is used for scaling. // |framebuffer_size| is used for scaling.
// On Ozone events are reported in the touchscreen's resolution, so // On Ozone events are reported in the touchscreen's resolution, so
// |touch_display| is used to determine the size and scale the event. // |touch_display| is used to determine the size and scale the event.
gfx::Transform GetTouchTransform( gfx::Transform GetTouchTransform(const ManagedDisplayInfo& display,
const display::ManagedDisplayInfo& display, const ManagedDisplayInfo& touch_display,
const display::ManagedDisplayInfo& touch_display, const ui::TouchscreenDevice& touchscreen,
const ui::TouchscreenDevice& touchscreen, const gfx::Size& framebuffer_size) const;
const gfx::Size& framebuffer_size) const;
// Returns the scaling factor for the touch radius such that it scales the // Returns the scaling factor for the touch radius such that it scales the
// radius from |touch_device|'s coordinate system to the |touch_display|'s // radius from |touch_device|'s coordinate system to the |touch_display|'s
// coordinate system. // coordinate system.
double GetTouchResolutionScale( double GetTouchResolutionScale(
const display::ManagedDisplayInfo& touch_display, const ManagedDisplayInfo& touch_display,
const ui::TouchscreenDevice& touch_device) const; const ui::TouchscreenDevice& touch_device) const;
// For the provided |display| update the touch radius mapping. // For the provided |display| update the touch radius mapping.
void UpdateTouchRadius(const display::ManagedDisplayInfo& display) const; void UpdateTouchRadius(const ManagedDisplayInfo& display) const;
// For a given |target_display| and |target_display_id| update the touch // For a given |target_display| and |target_display_id| update the touch
// transformation based on the touchscreen associated with |touch_display|. // transformation based on the touchscreen associated with |touch_display|.
...@@ -71,14 +73,18 @@ class ASH_EXPORT TouchTransformerController ...@@ -71,14 +73,18 @@ class ASH_EXPORT TouchTransformerController
// from which the events arrive. // from which the events arrive.
// |target_display| provides the dimensions to which the touch event will be // |target_display| provides the dimensions to which the touch event will be
// transformed. // transformed.
void UpdateTouchTransform( void UpdateTouchTransform(int64_t target_display_id,
int64_t target_display_id, const ManagedDisplayInfo& touch_display,
const display::ManagedDisplayInfo& touch_display, const ManagedDisplayInfo& target_display) const;
const display::ManagedDisplayInfo& target_display) const;
// Both |display_configurator_| and |display_manager_| are not owned and must
// outlive TouchTransformController.
DisplayConfigurator* display_configurator_;
DisplayManager* display_manager_;
DISALLOW_COPY_AND_ASSIGN(TouchTransformerController); DISALLOW_COPY_AND_ASSIGN(TouchTransformController);
}; };
} // namespace ash } // namespace display
#endif // ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_ #endif // UI_DISPLAY_MANAGER_CHROMEOS_TOUCH_TRANSFORM_CONTROLLER_H_
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