OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/events/devices/device_data_manager.h" | 5 #include "ui/events/devices/device_data_manager.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/display/display.h" | 10 #include "ui/display/display.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 void DeviceDataManager::TouchscreenInfo::Reset() { | 35 void DeviceDataManager::TouchscreenInfo::Reset() { |
36 radius_scale = 1.0; | 36 radius_scale = 1.0; |
37 target_display = display::Display::kInvalidDisplayID; | 37 target_display = display::Display::kInvalidDisplayID; |
38 device_transform = gfx::Transform(); | 38 device_transform = gfx::Transform(); |
39 } | 39 } |
40 | 40 |
41 // static | 41 // static |
42 DeviceDataManager* DeviceDataManager::instance_ = nullptr; | 42 DeviceDataManager* DeviceDataManager::instance_ = nullptr; |
43 | 43 |
44 DeviceDataManager::DeviceDataManager() {} | 44 DeviceDataManager::DeviceDataManager() { |
| 45 InputDeviceManager::SetInstance(this); |
| 46 } |
45 | 47 |
46 DeviceDataManager::~DeviceDataManager() {} | 48 DeviceDataManager::~DeviceDataManager() { |
| 49 InputDeviceManager::ClearInstance(); |
| 50 } |
47 | 51 |
48 // static | 52 // static |
49 DeviceDataManager* DeviceDataManager::instance() { return instance_; } | 53 DeviceDataManager* DeviceDataManager::instance() { return instance_; } |
50 | 54 |
51 // static | 55 // static |
52 void DeviceDataManager::set_instance(DeviceDataManager* instance) { | 56 void DeviceDataManager::set_instance(DeviceDataManager* instance) { |
53 DCHECK(instance) | 57 DCHECK(instance) |
54 << "Must reset the DeviceDataManager using DeleteInstance()."; | 58 << "Must reset the DeviceDataManager using DeleteInstance()."; |
55 DCHECK(!instance_) << "Can not set multiple instances of DeviceDataManager."; | 59 DCHECK(!instance_) << "Can not set multiple instances of DeviceDataManager."; |
56 instance_ = instance; | 60 instance_ = instance; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 float* y) { | 127 float* y) { |
124 if (IsTouchDeviceIdValid(touch_device_id)) { | 128 if (IsTouchDeviceIdValid(touch_device_id)) { |
125 gfx::Point3F point(*x, *y, 0.0); | 129 gfx::Point3F point(*x, *y, 0.0); |
126 const gfx::Transform& trans = touch_map_[touch_device_id].device_transform; | 130 const gfx::Transform& trans = touch_map_[touch_device_id].device_transform; |
127 trans.TransformPoint(&point); | 131 trans.TransformPoint(&point); |
128 *x = point.x(); | 132 *x = point.x(); |
129 *y = point.y(); | 133 *y = point.y(); |
130 } | 134 } |
131 } | 135 } |
132 | 136 |
| 137 const std::vector<TouchscreenDevice>& DeviceDataManager::GetTouchscreenDevices() |
| 138 const { |
| 139 return touchscreen_devices_; |
| 140 } |
| 141 |
| 142 const std::vector<InputDevice>& DeviceDataManager::GetKeyboardDevices() const { |
| 143 return keyboard_devices_; |
| 144 } |
| 145 |
| 146 const std::vector<InputDevice>& DeviceDataManager::GetMouseDevices() const { |
| 147 return mouse_devices_; |
| 148 } |
| 149 |
| 150 const std::vector<InputDevice>& DeviceDataManager::GetTouchpadDevices() const { |
| 151 return touchpad_devices_; |
| 152 } |
| 153 |
| 154 bool DeviceDataManager::AreDeviceListsComplete() const { |
| 155 return device_lists_complete_; |
| 156 } |
| 157 |
133 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( | 158 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( |
134 int touch_device_id) const { | 159 int touch_device_id) const { |
135 if (IsTouchDeviceIdValid(touch_device_id)) | 160 if (IsTouchDeviceIdValid(touch_device_id)) |
136 return touch_map_[touch_device_id].target_display; | 161 return touch_map_[touch_device_id].target_display; |
137 return display::Display::kInvalidDisplayID; | 162 return display::Display::kInvalidDisplayID; |
138 } | 163 } |
139 | 164 |
140 void DeviceDataManager::OnTouchscreenDevicesUpdated( | 165 void DeviceDataManager::OnTouchscreenDevicesUpdated( |
141 const std::vector<TouchscreenDevice>& devices) { | 166 const std::vector<TouchscreenDevice>& devices) { |
142 if (devices.size() == touchscreen_devices_.size() && | 167 if (devices.size() == touchscreen_devices_.size() && |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 245 |
221 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { | 246 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { |
222 touch_screens_enabled_ = enabled; | 247 touch_screens_enabled_ = enabled; |
223 } | 248 } |
224 | 249 |
225 bool DeviceDataManager::AreTouchscreensEnabled() const { | 250 bool DeviceDataManager::AreTouchscreensEnabled() const { |
226 return touch_screens_enabled_; | 251 return touch_screens_enabled_; |
227 } | 252 } |
228 | 253 |
229 } // namespace ui | 254 } // namespace ui |
OLD | NEW |