| Index: ui/events/devices/device_data_manager.cc
|
| diff --git a/ui/events/device_data_manager.cc b/ui/events/devices/device_data_manager.cc
|
| similarity index 53%
|
| rename from ui/events/device_data_manager.cc
|
| rename to ui/events/devices/device_data_manager.cc
|
| index d255b871abc80b10082d7408e92e25deafc7cb9a..44ca1fa7beccc0cef3c4beb8c83f7e5b9802aeb4 100644
|
| --- a/ui/events/device_data_manager.cc
|
| +++ b/ui/events/devices/device_data_manager.cc
|
| @@ -2,17 +2,25 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ui/events/device_data_manager.h"
|
| +#include "ui/events/devices/device_data_manager.h"
|
|
|
| #include "base/at_exit.h"
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| -#include "ui/events/input_device_event_observer.h"
|
| +#include "ui/events/devices/input_device_event_observer.h"
|
| #include "ui/gfx/display.h"
|
| #include "ui/gfx/geometry/point3_f.h"
|
|
|
| namespace ui {
|
|
|
| +namespace {
|
| +
|
| +bool InputDeviceEquals(const ui::InputDevice& a, const ui::InputDevice& b) {
|
| + return a.id == b.id;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| // static
|
| DeviceDataManager* DeviceDataManager::instance_ = NULL;
|
|
|
| @@ -23,10 +31,7 @@ DeviceDataManager::DeviceDataManager() {
|
| base::AtExitManager::RegisterTask(
|
| base::Bind(&base::DeletePointer<DeviceDataManager>, this));
|
|
|
| - for (int i = 0; i < kMaxDeviceNum; ++i) {
|
| - touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
|
| - touch_radius_scale_map_[i] = 1.0;
|
| - }
|
| + ClearTouchDeviceAssociations();
|
| }
|
|
|
| DeviceDataManager::~DeviceDataManager() {
|
| @@ -56,24 +61,25 @@ bool DeviceDataManager::HasInstance() {
|
| return instance_ != NULL;
|
| }
|
|
|
| -void DeviceDataManager::ClearTouchTransformerRecord() {
|
| +void DeviceDataManager::ClearTouchDeviceAssociations() {
|
| for (int i = 0; i < kMaxDeviceNum; i++) {
|
| touch_device_transformer_map_[i] = gfx::Transform();
|
| - touch_device_to_display_map_[i] = gfx::Display::kInvalidDisplayID;
|
| + touch_device_to_target_display_map_[i] = gfx::Display::kInvalidDisplayID;
|
| touch_radius_scale_map_[i] = 1.0;
|
| }
|
| }
|
|
|
| -bool DeviceDataManager::IsTouchDeviceIdValid(int touch_device_id) const {
|
| +bool DeviceDataManager::IsTouchDeviceIdValid(
|
| + int touch_device_id) const {
|
| return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum);
|
| }
|
|
|
| void DeviceDataManager::UpdateTouchInfoForDisplay(
|
| - int64_t display_id,
|
| + int64_t target_display_id,
|
| int touch_device_id,
|
| const gfx::Transform& touch_transformer) {
|
| if (IsTouchDeviceIdValid(touch_device_id)) {
|
| - touch_device_to_display_map_[touch_device_id] = display_id;
|
| + touch_device_to_target_display_map_[touch_device_id] = target_display_id;
|
| touch_device_transformer_map_[touch_device_id] = touch_transformer;
|
| }
|
| }
|
| @@ -103,19 +109,79 @@ void DeviceDataManager::ApplyTouchTransformer(int touch_device_id,
|
| }
|
| }
|
|
|
| -int64_t DeviceDataManager::GetDisplayForTouchDevice(int touch_device_id) const {
|
| +int64_t DeviceDataManager::GetTargetDisplayForTouchDevice(
|
| + int touch_device_id) const {
|
| if (IsTouchDeviceIdValid(touch_device_id))
|
| - return touch_device_to_display_map_[touch_device_id];
|
| + return touch_device_to_target_display_map_[touch_device_id];
|
| return gfx::Display::kInvalidDisplayID;
|
| }
|
|
|
| void DeviceDataManager::OnTouchscreenDevicesUpdated(
|
| const std::vector<TouchscreenDevice>& devices) {
|
| + if (devices.size() == touchscreen_devices_.size() &&
|
| + std::equal(devices.begin(),
|
| + devices.end(),
|
| + touchscreen_devices_.begin(),
|
| + InputDeviceEquals)) {
|
| + return;
|
| + }
|
| touchscreen_devices_ = devices;
|
| + FOR_EACH_OBSERVER(InputDeviceEventObserver,
|
| + observers_,
|
| + OnTouchscreenDeviceConfigurationChanged());
|
| +}
|
| +
|
| +void DeviceDataManager::OnKeyboardDevicesUpdated(
|
| + const std::vector<KeyboardDevice>& devices) {
|
| + if (devices.size() == keyboard_devices_.size() &&
|
| + std::equal(devices.begin(),
|
| + devices.end(),
|
| + keyboard_devices_.begin(),
|
| + InputDeviceEquals)) {
|
| + return;
|
| + }
|
| + keyboard_devices_ = devices;
|
| + FOR_EACH_OBSERVER(InputDeviceEventObserver,
|
| + observers_,
|
| + OnKeyboardDeviceConfigurationChanged());
|
| +}
|
| +
|
| +void DeviceDataManager::OnMouseDevicesUpdated(
|
| + const std::vector<InputDevice>& devices) {
|
| + if (devices.size() == mouse_devices_.size() &&
|
| + std::equal(devices.begin(),
|
| + devices.end(),
|
| + mouse_devices_.begin(),
|
| + InputDeviceEquals)) {
|
| + return;
|
| + }
|
| + mouse_devices_ = devices;
|
| + FOR_EACH_OBSERVER(InputDeviceEventObserver,
|
| + observers_,
|
| + OnMouseDeviceConfigurationChanged());
|
| +}
|
|
|
| +void DeviceDataManager::OnTouchpadDevicesUpdated(
|
| + const std::vector<InputDevice>& devices) {
|
| + if (devices.size() == touchpad_devices_.size() &&
|
| + std::equal(devices.begin(),
|
| + devices.end(),
|
| + touchpad_devices_.begin(),
|
| + InputDeviceEquals)) {
|
| + return;
|
| + }
|
| + touchpad_devices_ = devices;
|
| FOR_EACH_OBSERVER(InputDeviceEventObserver,
|
| observers_,
|
| - OnInputDeviceConfigurationChanged());
|
| + OnTouchpadDeviceConfigurationChanged());
|
| +}
|
| +
|
| +void DeviceDataManager::OnDeviceListsComplete() {
|
| + if (!device_lists_complete_) {
|
| + device_lists_complete_ = true;
|
| + FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_,
|
| + OnDeviceListsComplete());
|
| + }
|
| }
|
|
|
| void DeviceDataManager::AddObserver(InputDeviceEventObserver* observer) {
|
|
|