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/events/devices/input_device_event_observer.h" | 11 #include "ui/events/devices/input_device_event_observer.h" |
11 #include "ui/gfx/display.h" | |
12 #include "ui/gfx/geometry/point3_f.h" | 12 #include "ui/gfx/geometry/point3_f.h" |
13 | 13 |
14 // This macro provides the implementation for the observer notification methods. | 14 // This macro provides the implementation for the observer notification methods. |
15 #define NOTIFY_OBSERVERS(method_name, observer_method) \ | 15 #define NOTIFY_OBSERVERS(method_name, observer_method) \ |
16 void DeviceDataManager::method_name() { \ | 16 void DeviceDataManager::method_name() { \ |
17 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, \ | 17 FOR_EACH_OBSERVER(InputDeviceEventObserver, observers_, \ |
18 observer_method()); \ | 18 observer_method()); \ |
19 } | 19 } |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 // static | 75 // static |
76 bool DeviceDataManager::HasInstance() { | 76 bool DeviceDataManager::HasInstance() { |
77 return instance_ != NULL; | 77 return instance_ != NULL; |
78 } | 78 } |
79 | 79 |
80 void DeviceDataManager::ClearTouchDeviceAssociations() { | 80 void DeviceDataManager::ClearTouchDeviceAssociations() { |
81 for (int i = 0; i < kMaxDeviceNum; i++) { | 81 for (int i = 0; i < kMaxDeviceNum; i++) { |
82 touch_device_transformer_map_[i] = gfx::Transform(); | 82 touch_device_transformer_map_[i] = gfx::Transform(); |
83 touch_device_to_target_display_map_[i] = gfx::Display::kInvalidDisplayID; | 83 touch_device_to_target_display_map_[i] = |
| 84 display::Display::kInvalidDisplayID; |
84 touch_radius_scale_map_[i] = 1.0; | 85 touch_radius_scale_map_[i] = 1.0; |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 bool DeviceDataManager::IsTouchDeviceIdValid( | 89 bool DeviceDataManager::IsTouchDeviceIdValid( |
89 int touch_device_id) const { | 90 int touch_device_id) const { |
90 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); | 91 return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum); |
91 } | 92 } |
92 | 93 |
93 void DeviceDataManager::UpdateTouchInfoForDisplay( | 94 void DeviceDataManager::UpdateTouchInfoForDisplay( |
(...skipping 28 matching lines...) Expand all Loading... |
122 trans.TransformPoint(&point); | 123 trans.TransformPoint(&point); |
123 *x = point.x(); | 124 *x = point.x(); |
124 *y = point.y(); | 125 *y = point.y(); |
125 } | 126 } |
126 } | 127 } |
127 | 128 |
128 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( | 129 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( |
129 int touch_device_id) const { | 130 int touch_device_id) const { |
130 if (IsTouchDeviceIdValid(touch_device_id)) | 131 if (IsTouchDeviceIdValid(touch_device_id)) |
131 return touch_device_to_target_display_map_[touch_device_id]; | 132 return touch_device_to_target_display_map_[touch_device_id]; |
132 return gfx::Display::kInvalidDisplayID; | 133 return display::Display::kInvalidDisplayID; |
133 } | 134 } |
134 | 135 |
135 void DeviceDataManager::OnTouchscreenDevicesUpdated( | 136 void DeviceDataManager::OnTouchscreenDevicesUpdated( |
136 const std::vector<TouchscreenDevice>& devices) { | 137 const std::vector<TouchscreenDevice>& devices) { |
137 if (devices.size() == touchscreen_devices_.size() && | 138 if (devices.size() == touchscreen_devices_.size() && |
138 std::equal(devices.begin(), | 139 std::equal(devices.begin(), |
139 devices.end(), | 140 devices.end(), |
140 touchscreen_devices_.begin(), | 141 touchscreen_devices_.begin(), |
141 InputDeviceEquals)) { | 142 InputDeviceEquals)) { |
142 return; | 143 return; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 216 |
216 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { | 217 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { |
217 touch_screens_enabled_ = enabled; | 218 touch_screens_enabled_ = enabled; |
218 } | 219 } |
219 | 220 |
220 bool DeviceDataManager::AreTouchscreensEnabled() const { | 221 bool DeviceDataManager::AreTouchscreensEnabled() const { |
221 return touch_screens_enabled_; | 222 return touch_screens_enabled_; |
222 } | 223 } |
223 | 224 |
224 } // namespace ui | 225 } // namespace ui |
OLD | NEW |