| 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/types/display_constants.h" |
| 11 #include "ui/events/devices/input_device_event_observer.h" | 11 #include "ui/events/devices/input_device_event_observer.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_decl, observer_call) \ | 15 #define NOTIFY_OBSERVERS(method_decl, observer_call) \ |
| 16 void DeviceDataManager::method_decl { \ | 16 void DeviceDataManager::method_decl { \ |
| 17 for (InputDeviceEventObserver& observer : observers_) \ | 17 for (InputDeviceEventObserver& observer : observers_) \ |
| 18 observer.observer_call; \ | 18 observer.observer_call; \ |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace ui { | 21 namespace ui { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 bool InputDeviceEquals(const ui::InputDevice& a, const ui::InputDevice& b) { | 25 bool InputDeviceEquals(const ui::InputDevice& a, const ui::InputDevice& b) { |
| 26 return a.id == b.id; | 26 return a.id == b.id; |
| 27 } | 27 } |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 DeviceDataManager::TouchscreenInfo::TouchscreenInfo() { | 31 DeviceDataManager::TouchscreenInfo::TouchscreenInfo() { |
| 32 Reset(); | 32 Reset(); |
| 33 } | 33 } |
| 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::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); | 45 InputDeviceManager::SetInstance(this); |
| 46 } | 46 } |
| 47 | 47 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool DeviceDataManager::AreDeviceListsComplete() const { | 154 bool DeviceDataManager::AreDeviceListsComplete() const { |
| 155 return device_lists_complete_; | 155 return device_lists_complete_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( | 158 int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( |
| 159 int touch_device_id) const { | 159 int touch_device_id) const { |
| 160 if (IsTouchDeviceIdValid(touch_device_id)) | 160 if (IsTouchDeviceIdValid(touch_device_id)) |
| 161 return touch_map_[touch_device_id].target_display; | 161 return touch_map_[touch_device_id].target_display; |
| 162 return display::Display::kInvalidDisplayID; | 162 return display::kInvalidDisplayId; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void DeviceDataManager::OnTouchscreenDevicesUpdated( | 165 void DeviceDataManager::OnTouchscreenDevicesUpdated( |
| 166 const std::vector<TouchscreenDevice>& devices) { | 166 const std::vector<TouchscreenDevice>& devices) { |
| 167 if (devices.size() == touchscreen_devices_.size() && | 167 if (devices.size() == touchscreen_devices_.size() && |
| 168 std::equal(devices.begin(), | 168 std::equal(devices.begin(), |
| 169 devices.end(), | 169 devices.end(), |
| 170 touchscreen_devices_.begin(), | 170 touchscreen_devices_.begin(), |
| 171 InputDeviceEquals)) { | 171 InputDeviceEquals)) { |
| 172 return; | 172 return; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { | 253 void DeviceDataManager::SetTouchscreensEnabled(bool enabled) { |
| 254 touch_screens_enabled_ = enabled; | 254 touch_screens_enabled_ = enabled; |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool DeviceDataManager::AreTouchscreensEnabled() const { | 257 bool DeviceDataManager::AreTouchscreensEnabled() const { |
| 258 return touch_screens_enabled_; | 258 return touch_screens_enabled_; |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace ui | 261 } // namespace ui |
| OLD | NEW |