| 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 #ifndef UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ |
| 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <gestures/gestures.h> | 8 #include <gestures/gestures.h> |
| 9 #include <libevdev/libevdev.h> | 9 #include <libevdev/libevdev.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <ostream> | 15 #include <ostream> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <unordered_map> |
| 17 #include <vector> | 18 #include <vector> |
| 18 | 19 |
| 19 #include "base/containers/scoped_ptr_hash_map.h" | |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "ui/events/ozone/evdev/event_device_info.h" | 22 #include "ui/events/ozone/evdev/event_device_info.h" |
| 23 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" | 23 #include "ui/events/ozone/evdev/events_ozone_evdev_export.h" |
| 24 | 24 |
| 25 namespace ui { | 25 namespace ui { |
| 26 | 26 |
| 27 class GesturesPropFunctionsWrapper; | 27 class GesturesPropFunctionsWrapper; |
| 28 class GestureInterpreterLibevdevCros; | 28 class GestureInterpreterLibevdevCros; |
| 29 | 29 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 // Get the (Evdev) device name. Mostly used for the logging purpose. | 106 // Get the (Evdev) device name. Mostly used for the logging purpose. |
| 107 std::string GetDeviceNameById(const DeviceId device_id); | 107 std::string GetDeviceNameById(const DeviceId device_id); |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 friend class GesturesPropFunctionsWrapper; | 110 friend class GesturesPropFunctionsWrapper; |
| 111 | 111 |
| 112 // Mapping table from a device id to its device pointer. | 112 // Mapping table from a device id to its device pointer. |
| 113 typedef std::map<DeviceId, DevicePtr> DeviceMap; | 113 typedef std::map<DeviceId, DevicePtr> DeviceMap; |
| 114 | 114 |
| 115 // Mapping table from a device id to its property data. | |
| 116 // GestureDevicePropertyData contains both properties in use and default | |
| 117 // properties whose values will be applied upon the device attachment. | |
| 118 typedef base::ScopedPtrHashMap< | |
| 119 DeviceId, | |
| 120 std::unique_ptr<internal::GestureDevicePropertyData>> | |
| 121 ScopedDeviceDataMap; | |
| 122 | |
| 123 // Register a device. Setup data-structures and the device's default | 115 // Register a device. Setup data-structures and the device's default |
| 124 // properties. | 116 // properties. |
| 125 void RegisterDevice(const DeviceId id, const DevicePtr device); | 117 void RegisterDevice(const DeviceId id, const DevicePtr device); |
| 126 | 118 |
| 127 // Unregister a device. Remove all of its properties being tracked. | 119 // Unregister a device. Remove all of its properties being tracked. |
| 128 void UnregisterDevice(const DeviceId id); | 120 void UnregisterDevice(const DeviceId id); |
| 129 | 121 |
| 130 // Called by functions in GesturesPropFunctionsWrapper to manipulate | 122 // Called by functions in GesturesPropFunctionsWrapper to manipulate |
| 131 // properties. Note these functions do not new/delete the GesturesProp | 123 // properties. Note these functions do not new/delete the GesturesProp |
| 132 // pointers. It is caller's responsibility to manage them. | 124 // pointers. It is caller's responsibility to manage them. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 159 // Create a property that comes from the conf files. | 151 // Create a property that comes from the conf files. |
| 160 std::unique_ptr<GesturesProp> CreateDefaultProperty(const std::string& name, | 152 std::unique_ptr<GesturesProp> CreateDefaultProperty(const std::string& name, |
| 161 const std::string& value); | 153 const std::string& value); |
| 162 | 154 |
| 163 // Setup default property values for a newly found device. | 155 // Setup default property values for a newly found device. |
| 164 void SetupDefaultProperties(const DeviceId device_id, const DevicePtr device); | 156 void SetupDefaultProperties(const DeviceId device_id, const DevicePtr device); |
| 165 | 157 |
| 166 // Map from device ids to device pointers. | 158 // Map from device ids to device pointers. |
| 167 DeviceMap device_map_; | 159 DeviceMap device_map_; |
| 168 | 160 |
| 169 // GestureDevicePropertyData indexed by their respective device ids. Owns the | 161 // Mapping table from a device id to its property data. |
| 170 // objects. | 162 // GestureDevicePropertyData contains both properties in use and default |
| 171 ScopedDeviceDataMap device_data_map_; | 163 // properties whose values will be applied upon the device attachment. |
| 164 std::unordered_map<DeviceId, |
| 165 std::unique_ptr<internal::GestureDevicePropertyData>> |
| 166 device_data_map_; |
| 172 | 167 |
| 173 // A vector of parsed sections in configuration files. Owns MatchCriterias, | 168 // A vector of parsed sections in configuration files. Owns MatchCriterias, |
| 174 // GesturesProps and ConfigurationSections in it. | 169 // GesturesProps and ConfigurationSections in it. |
| 175 std::vector<std::unique_ptr<internal::ConfigurationSection>> configurations_; | 170 std::vector<std::unique_ptr<internal::ConfigurationSection>> configurations_; |
| 176 | 171 |
| 177 DISALLOW_COPY_AND_ASSIGN(GesturePropertyProvider); | 172 DISALLOW_COPY_AND_ASSIGN(GesturePropertyProvider); |
| 178 }; | 173 }; |
| 179 | 174 |
| 180 // Wrapper of GesturesProp related functions. We group them together so that we | 175 // Wrapper of GesturesProp related functions. We group them together so that we |
| 181 // can friend them all at once. | 176 // can friend them all at once. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // Handler function pointers and the data to be passed to them when the | 332 // Handler function pointers and the data to be passed to them when the |
| 338 // property is accessed. | 333 // property is accessed. |
| 339 GesturesPropGetHandler get_; | 334 GesturesPropGetHandler get_; |
| 340 GesturesPropSetHandler set_; | 335 GesturesPropSetHandler set_; |
| 341 void* handler_data_; | 336 void* handler_data_; |
| 342 | 337 |
| 343 DISALLOW_COPY_AND_ASSIGN(GesturesProp); | 338 DISALLOW_COPY_AND_ASSIGN(GesturesProp); |
| 344 }; | 339 }; |
| 345 | 340 |
| 346 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ | 341 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ |
| OLD | NEW |