| 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/ozone/evdev/libgestures_glue/gesture_property_provider.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" |
| 6 | 6 |
| 7 #include <gestures/gestures.h> | 7 #include <gestures/gestures.h> |
| 8 #include <libevdev/libevdev.h> | 8 #include <libevdev/libevdev.h> |
| 9 | 9 |
| 10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 ~MatchIsTouchscreen() override {} | 708 ~MatchIsTouchscreen() override {} |
| 709 bool Match(const DevicePtr device) override; | 709 bool Match(const DevicePtr device) override; |
| 710 }; | 710 }; |
| 711 | 711 |
| 712 // Struct for sections in xorg conf files. | 712 // Struct for sections in xorg conf files. |
| 713 struct ConfigurationSection { | 713 struct ConfigurationSection { |
| 714 typedef ui::GesturePropertyProvider::DevicePtr DevicePtr; | 714 typedef ui::GesturePropertyProvider::DevicePtr DevicePtr; |
| 715 ConfigurationSection() {} | 715 ConfigurationSection() {} |
| 716 bool Match(const DevicePtr device); | 716 bool Match(const DevicePtr device); |
| 717 std::string identifier; | 717 std::string identifier; |
| 718 ScopedVector<MatchCriteria> criterias; | 718 std::vector<scoped_ptr<MatchCriteria>> criterias; |
| 719 ScopedVector<GesturesProp> properties; | 719 std::vector<scoped_ptr<GesturesProp>> properties; |
| 720 }; | 720 }; |
| 721 | 721 |
| 722 MatchCriteria::MatchCriteria(const std::string& arg) { | 722 MatchCriteria::MatchCriteria(const std::string& arg) { |
| 723 // TODO(sheckylin): Should we trim all tokens here? | 723 // TODO(sheckylin): Should we trim all tokens here? |
| 724 args_ = base::SplitString( | 724 args_ = base::SplitString( |
| 725 arg, "|", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 725 arg, "|", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 726 if (args_.empty()) { | 726 if (args_.empty()) { |
| 727 LOG(ERROR) << "Empty match pattern found, will evaluate to the default " | 727 LOG(ERROR) << "Empty match pattern found, will evaluate to the default " |
| 728 "value (true): \"" << arg << "\""; | 728 "value (true): \"" << arg << "\""; |
| 729 } | 729 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 void GesturePropertyProvider::UnregisterDevice(const DeviceId id) { | 943 void GesturePropertyProvider::UnregisterDevice(const DeviceId id) { |
| 944 DeviceMap::const_iterator it = device_map_.find(id); | 944 DeviceMap::const_iterator it = device_map_.find(id); |
| 945 if (it == device_map_.end()) | 945 if (it == device_map_.end()) |
| 946 return; | 946 return; |
| 947 device_data_map_.erase(id); | 947 device_data_map_.erase(id); |
| 948 device_map_.erase(it); | 948 device_map_.erase(it); |
| 949 } | 949 } |
| 950 | 950 |
| 951 void GesturePropertyProvider::AddProperty(const DeviceId device_id, | 951 void GesturePropertyProvider::AddProperty(const DeviceId device_id, |
| 952 const std::string& name, | 952 const std::string& name, |
| 953 GesturesProp* property) { | 953 scoped_ptr<GesturesProp> property) { |
| 954 // The look-up should never fail because ideally a property can only be | 954 // The look-up should never fail because ideally a property can only be |
| 955 // created with GesturesPropCreate* functions from the gesture lib side. | 955 // created with GesturesPropCreate* functions from the gesture lib side. |
| 956 // Therefore, we simply return on failure. | 956 // Therefore, we simply return on failure. |
| 957 internal::GestureDevicePropertyData* device_data = | 957 internal::GestureDevicePropertyData* device_data = |
| 958 device_data_map_.get(device_id); | 958 device_data_map_.get(device_id); |
| 959 if (device_data) | 959 if (device_data) |
| 960 device_data->properties.set(name, scoped_ptr<GesturesProp>(property)); | 960 device_data->properties.set(name, std::move(property)); |
| 961 } | 961 } |
| 962 | 962 |
| 963 void GesturePropertyProvider::DeleteProperty(const DeviceId device_id, | 963 void GesturePropertyProvider::DeleteProperty(const DeviceId device_id, |
| 964 const std::string& name) { | 964 const std::string& name) { |
| 965 internal::GestureDevicePropertyData* device_data = | 965 internal::GestureDevicePropertyData* device_data = |
| 966 device_data_map_.get(device_id); | 966 device_data_map_.get(device_id); |
| 967 if (device_data) | 967 if (device_data) |
| 968 device_data->properties.erase(name); | 968 device_data->properties.erase(name); |
| 969 } | 969 } |
| 970 | 970 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 // (e.g., "Non-linearity"). | 1031 // (e.g., "Non-linearity"). |
| 1032 | 1032 |
| 1033 // Break the content into sections, lines and then pieces. | 1033 // Break the content into sections, lines and then pieces. |
| 1034 // Sections are delimited by the "EndSection" keyword. | 1034 // Sections are delimited by the "EndSection" keyword. |
| 1035 // Lines are delimited by "\n". | 1035 // Lines are delimited by "\n". |
| 1036 // Pieces are delimited by all white-spaces. | 1036 // Pieces are delimited by all white-spaces. |
| 1037 std::vector<std::string> sections; | 1037 std::vector<std::string> sections; |
| 1038 base::SplitStringUsingSubstr(content, "EndSection", §ions); | 1038 base::SplitStringUsingSubstr(content, "EndSection", §ions); |
| 1039 for (size_t i = 0; i < sections.size(); ++i) { | 1039 for (size_t i = 0; i < sections.size(); ++i) { |
| 1040 // Create a new configuration section. | 1040 // Create a new configuration section. |
| 1041 configurations_.push_back(new internal::ConfigurationSection()); | 1041 configurations_.push_back( |
| 1042 internal::ConfigurationSection* config = configurations_.back(); | 1042 make_scoped_ptr(new internal::ConfigurationSection())); |
| 1043 internal::ConfigurationSection* config = configurations_.back().get(); |
| 1043 | 1044 |
| 1044 // Break the section into lines. | 1045 // Break the section into lines. |
| 1045 base::StringTokenizer lines(sections[i], "\n"); | 1046 base::StringTokenizer lines(sections[i], "\n"); |
| 1046 bool is_input_class_section = true; | 1047 bool is_input_class_section = true; |
| 1047 bool has_checked_section_type = false; | 1048 bool has_checked_section_type = false; |
| 1048 while (is_input_class_section && lines.GetNext()) { | 1049 while (is_input_class_section && lines.GetNext()) { |
| 1049 // Parse the line w.r.t. the xorg-conf format. | 1050 // Parse the line w.r.t. the xorg-conf format. |
| 1050 std::string line(lines.token()); | 1051 std::string line(lines.token()); |
| 1051 | 1052 |
| 1052 // Skip empty lines. | 1053 // Skip empty lines. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 DVLOG(2) << "Identifier: " << arg; | 1105 DVLOG(2) << "Identifier: " << arg; |
| 1105 config->identifier = arg; | 1106 config->identifier = arg; |
| 1106 next_is_identifier = false; | 1107 next_is_identifier = false; |
| 1107 break; | 1108 break; |
| 1108 } else if (next_is_option_name) { | 1109 } else if (next_is_option_name) { |
| 1109 // TODO(sheckylin): Support option "Ignore". | 1110 // TODO(sheckylin): Support option "Ignore". |
| 1110 option_name = arg; | 1111 option_name = arg; |
| 1111 next_is_option_value = true; | 1112 next_is_option_value = true; |
| 1112 next_is_option_name = false; | 1113 next_is_option_name = false; |
| 1113 } else if (next_is_option_value) { | 1114 } else if (next_is_option_value) { |
| 1114 GesturesProp* property = CreateDefaultProperty(option_name, arg); | 1115 scoped_ptr<GesturesProp> property = |
| 1116 CreateDefaultProperty(option_name, arg); |
| 1115 if (property) | 1117 if (property) |
| 1116 config->properties.push_back(property); | 1118 config->properties.push_back(std::move(property)); |
| 1117 next_is_option_value = false; | 1119 next_is_option_value = false; |
| 1118 break; | 1120 break; |
| 1119 } else if (next_is_match_criteria) { | 1121 } else if (next_is_match_criteria) { |
| 1120 // Skip all match types that are not supported. | 1122 // Skip all match types that are not supported. |
| 1121 if (IsMatchTypeSupported(match_type)) { | 1123 if (IsMatchTypeSupported(match_type)) { |
| 1122 internal::MatchCriteria* criteria = | 1124 scoped_ptr<internal::MatchCriteria> criteria = |
| 1123 CreateMatchCriteria(match_type, arg); | 1125 CreateMatchCriteria(match_type, arg); |
| 1124 if (criteria) | 1126 if (criteria) |
| 1125 config->criterias.push_back(criteria); | 1127 config->criterias.push_back(std::move(criteria)); |
| 1126 } | 1128 } |
| 1127 next_is_match_criteria = false; | 1129 next_is_match_criteria = false; |
| 1128 break; | 1130 break; |
| 1129 } | 1131 } |
| 1130 } else { | 1132 } else { |
| 1131 // If the section type hasn't been decided yet, look for it. | 1133 // If the section type hasn't been decided yet, look for it. |
| 1132 // Otherwise, look for valid entries according to the spec. | 1134 // Otherwise, look for valid entries according to the spec. |
| 1133 if (has_checked_section_type) { | 1135 if (has_checked_section_type) { |
| 1134 if (piece == "Driver") { | 1136 if (piece == "Driver") { |
| 1135 // "Driver" field is meaningless for non-X11 setup. | 1137 // "Driver" field is meaningless for non-X11 setup. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1160 LOG(ERROR) << "Error parsing line: " << lines.token(); | 1162 LOG(ERROR) << "Error parsing line: " << lines.token(); |
| 1161 has_error = true; | 1163 has_error = true; |
| 1162 } | 1164 } |
| 1163 break; | 1165 break; |
| 1164 } | 1166 } |
| 1165 } | 1167 } |
| 1166 | 1168 |
| 1167 // The value of a boolean option is skipped (default is true). | 1169 // The value of a boolean option is skipped (default is true). |
| 1168 if (!has_error && (next_is_option_value || next_is_match_criteria)) { | 1170 if (!has_error && (next_is_option_value || next_is_match_criteria)) { |
| 1169 if (next_is_option_value) { | 1171 if (next_is_option_value) { |
| 1170 GesturesProp* property = CreateDefaultProperty(option_name, "on"); | 1172 scoped_ptr<GesturesProp> property = |
| 1173 CreateDefaultProperty(option_name, "on"); |
| 1171 if (property) | 1174 if (property) |
| 1172 config->properties.push_back(property); | 1175 config->properties.push_back(std::move(property)); |
| 1173 } else if (IsMatchTypeSupported(match_type) && | 1176 } else if (IsMatchTypeSupported(match_type) && |
| 1174 IsMatchDeviceType(match_type)) { | 1177 IsMatchDeviceType(match_type)) { |
| 1175 internal::MatchCriteria* criteria = | 1178 scoped_ptr<internal::MatchCriteria> criteria = |
| 1176 CreateMatchCriteria(match_type, "on"); | 1179 CreateMatchCriteria(match_type, "on"); |
| 1177 if (criteria) | 1180 if (criteria) |
| 1178 config->criterias.push_back(criteria); | 1181 config->criterias.push_back(std::move(criteria)); |
| 1179 } | 1182 } |
| 1180 } | 1183 } |
| 1181 } | 1184 } |
| 1182 | 1185 |
| 1183 // Remove useless config sections. | 1186 // Remove useless config sections. |
| 1184 if (!is_input_class_section || | 1187 if (!is_input_class_section || |
| 1185 (config->criterias.empty() && config->properties.empty())) { | 1188 (config->criterias.empty() && config->properties.empty())) { |
| 1186 configurations_.pop_back(); | 1189 configurations_.pop_back(); |
| 1187 } | 1190 } |
| 1188 } | 1191 } |
| 1189 } | 1192 } |
| 1190 | 1193 |
| 1191 internal::MatchCriteria* GesturePropertyProvider::CreateMatchCriteria( | 1194 scoped_ptr<internal::MatchCriteria> |
| 1192 const std::string& match_type, | 1195 GesturePropertyProvider::CreateMatchCriteria(const std::string& match_type, |
| 1193 const std::string& arg) { | 1196 const std::string& arg) { |
| 1194 DVLOG(2) << "Creating match criteria: (" << match_type << ", " << arg << ")"; | 1197 DVLOG(2) << "Creating match criteria: (" << match_type << ", " << arg << ")"; |
| 1195 if (match_type == "MatchProduct") | 1198 if (match_type == "MatchProduct") |
| 1196 return new internal::MatchProduct(arg); | 1199 return make_scoped_ptr(new internal::MatchProduct(arg)); |
| 1197 if (match_type == "MatchDevicePath") | 1200 if (match_type == "MatchDevicePath") |
| 1198 return new internal::MatchDevicePath(arg); | 1201 return make_scoped_ptr(new internal::MatchDevicePath(arg)); |
| 1199 if (match_type == "MatchUSBID") | 1202 if (match_type == "MatchUSBID") |
| 1200 return new internal::MatchUSBID(arg); | 1203 return make_scoped_ptr(new internal::MatchUSBID(arg)); |
| 1201 if (match_type == "MatchIsPointer") | 1204 if (match_type == "MatchIsPointer") |
| 1202 return new internal::MatchIsPointer(arg); | 1205 return make_scoped_ptr(new internal::MatchIsPointer(arg)); |
| 1203 if (match_type == "MatchIsTouchpad") | 1206 if (match_type == "MatchIsTouchpad") |
| 1204 return new internal::MatchIsTouchpad(arg); | 1207 return make_scoped_ptr(new internal::MatchIsTouchpad(arg)); |
| 1205 if (match_type == "MatchIsTouchscreen") | 1208 if (match_type == "MatchIsTouchscreen") |
| 1206 return new internal::MatchIsTouchscreen(arg); | 1209 return make_scoped_ptr(new internal::MatchIsTouchscreen(arg)); |
| 1207 NOTREACHED(); | 1210 NOTREACHED(); |
| 1208 return NULL; | 1211 return NULL; |
| 1209 } | 1212 } |
| 1210 | 1213 |
| 1211 GesturesProp* GesturePropertyProvider::CreateDefaultProperty( | 1214 scoped_ptr<GesturesProp> GesturePropertyProvider::CreateDefaultProperty( |
| 1212 const std::string& name, | 1215 const std::string& name, |
| 1213 const std::string& value) { | 1216 const std::string& value) { |
| 1214 // Our parsing rule: | 1217 // Our parsing rule: |
| 1215 // 1. No hex or oct number is accepted. | 1218 // 1. No hex or oct number is accepted. |
| 1216 // 2. All numbers will be stored as double. | 1219 // 2. All numbers will be stored as double. |
| 1217 // 3. Array elements can be separated by both white-spaces or commas. | 1220 // 3. Array elements can be separated by both white-spaces or commas. |
| 1218 // 4. A token is treated as numeric either if it is one of the special | 1221 // 4. A token is treated as numeric either if it is one of the special |
| 1219 // keywords for boolean values (on, true, yes, off, false, no) or if | 1222 // keywords for boolean values (on, true, yes, off, false, no) or if |
| 1220 // base::StringToDouble succeeds. | 1223 // base::StringToDouble succeeds. |
| 1221 // 5. The property is treated as numeric if and only if all of its elements | 1224 // 5. The property is treated as numeric if and only if all of its elements |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1247 bool success = base::StringToDouble(token, &real_result); | 1250 bool success = base::StringToDouble(token, &real_result); |
| 1248 if (!success) { | 1251 if (!success) { |
| 1249 is_all_numeric = false; | 1252 is_all_numeric = false; |
| 1250 break; | 1253 break; |
| 1251 } | 1254 } |
| 1252 numbers.push_back(real_result); | 1255 numbers.push_back(real_result); |
| 1253 } | 1256 } |
| 1254 | 1257 |
| 1255 // Create the GesturesProp. Array properties need to contain at least one | 1258 // Create the GesturesProp. Array properties need to contain at least one |
| 1256 // number and may contain numbers only. | 1259 // number and may contain numbers only. |
| 1257 GesturesProp* property = NULL; | 1260 scoped_ptr<GesturesProp> property; |
| 1258 if (is_all_numeric && numbers.size()) { | 1261 if (is_all_numeric && numbers.size()) { |
| 1259 property = new GesturesDoubleProp( | 1262 property.reset(new GesturesDoubleProp(name, numbers.size(), NULL, |
| 1260 name, numbers.size(), NULL, numbers.data(), NULL); | 1263 numbers.data(), NULL)); |
| 1261 } else { | 1264 } else { |
| 1262 property = new GesturesStringProp(name, NULL, value.c_str(), NULL); | 1265 property.reset(new GesturesStringProp(name, NULL, value.c_str(), NULL)); |
| 1263 } | 1266 } |
| 1264 | 1267 |
| 1265 DVLOG(2) << "Prop: " << *property; | 1268 DVLOG(2) << "Prop: " << *property; |
| 1266 // The function will always succeed for now but it may change later if we | 1269 // The function will always succeed for now but it may change later if we |
| 1267 // specify some name or args as invalid. | 1270 // specify some name or args as invalid. |
| 1268 return property; | 1271 return property; |
| 1269 } | 1272 } |
| 1270 | 1273 |
| 1271 void GesturePropertyProvider::SetupDefaultProperties(const DeviceId device_id, | 1274 void GesturePropertyProvider::SetupDefaultProperties(const DeviceId device_id, |
| 1272 const DevicePtr device) { | 1275 const DevicePtr device) { |
| 1273 DVLOG(2) << "Setting up default properties for (" << device << ", " | 1276 DVLOG(2) << "Setting up default properties for (" << device << ", " |
| 1274 << device_id << ", " << device->info.name << ")"; | 1277 << device_id << ", " << device->info.name << ")"; |
| 1275 | 1278 |
| 1276 // Go through all parsed sections. | 1279 // Go through all parsed sections. |
| 1277 internal::PropertiesMap& property_map = | 1280 internal::PropertiesMap& property_map = |
| 1278 device_data_map_.get(device_id)->default_properties; | 1281 device_data_map_.get(device_id)->default_properties; |
| 1279 for (size_t i = 0; i < configurations_.size(); ++i) { | 1282 for (const auto& configuration : configurations_) { |
| 1280 if (configurations_[i]->Match(device)) { | 1283 if (configuration->Match(device)) { |
| 1281 DVLOG(2) << "Conf section \"" << configurations_[i]->identifier | 1284 DVLOG(2) << "Conf section \"" << configuration->identifier |
| 1282 << "\" is matched"; | 1285 << "\" is matched"; |
| 1283 for (size_t j = 0; j < configurations_[i]->properties.size(); j++) { | 1286 for (const auto& property : configuration->properties) { |
| 1284 GesturesProp* property = configurations_[i]->properties[j]; | |
| 1285 // We can't use insert here because a property may be set for several | 1287 // We can't use insert here because a property may be set for several |
| 1286 // times along the way. | 1288 // times along the way. |
| 1287 property_map[property->name()] = property; | 1289 property_map[property->name()] = property.get(); |
| 1288 } | 1290 } |
| 1289 } | 1291 } |
| 1290 } | 1292 } |
| 1291 } | 1293 } |
| 1292 | 1294 |
| 1293 GesturesProp* GesturesPropFunctionsWrapper::CreateInt(void* device_data, | 1295 GesturesProp* GesturesPropFunctionsWrapper::CreateInt(void* device_data, |
| 1294 const char* name, | 1296 const char* name, |
| 1295 int* value, | 1297 int* value, |
| 1296 size_t count, | 1298 size_t count, |
| 1297 const int* init) { | 1299 const int* init) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 | 1331 |
| 1330 GesturesProp* GesturesPropFunctionsWrapper::CreateString(void* device_data, | 1332 GesturesProp* GesturesPropFunctionsWrapper::CreateString(void* device_data, |
| 1331 const char* name, | 1333 const char* name, |
| 1332 const char** value, | 1334 const char** value, |
| 1333 const char* init) { | 1335 const char* init) { |
| 1334 GesturesProp* default_property = NULL; | 1336 GesturesProp* default_property = NULL; |
| 1335 if (!PreCreateProperty(device_data, name, &default_property)) | 1337 if (!PreCreateProperty(device_data, name, &default_property)) |
| 1336 return NULL; | 1338 return NULL; |
| 1337 GesturesProp* property = | 1339 GesturesProp* property = |
| 1338 new GesturesStringProp(name, value, init, default_property); | 1340 new GesturesStringProp(name, value, init, default_property); |
| 1339 | 1341 PostCreateProperty(device_data, name, make_scoped_ptr(property)); |
| 1340 PostCreateProperty(device_data, name, property); | |
| 1341 return property; | 1342 return property; |
| 1342 } | 1343 } |
| 1343 | 1344 |
| 1344 void GesturesPropFunctionsWrapper::RegisterHandlers( | 1345 void GesturesPropFunctionsWrapper::RegisterHandlers( |
| 1345 void* device_data, | 1346 void* device_data, |
| 1346 GesturesProp* property, | 1347 GesturesProp* property, |
| 1347 void* handler_data, | 1348 void* handler_data, |
| 1348 GesturesPropGetHandler get, | 1349 GesturesPropGetHandler get, |
| 1349 GesturesPropSetHandler set) { | 1350 GesturesPropSetHandler set) { |
| 1350 // Sanity checks | 1351 // Sanity checks |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 size_t count, | 1453 size_t count, |
| 1453 const T* init) { | 1454 const T* init) { |
| 1454 // Create the property. Use the default property value if possible. | 1455 // Create the property. Use the default property value if possible. |
| 1455 GesturesProp* default_property = NULL; | 1456 GesturesProp* default_property = NULL; |
| 1456 if (!PreCreateProperty(device_data, name, &default_property)) | 1457 if (!PreCreateProperty(device_data, name, &default_property)) |
| 1457 return NULL; | 1458 return NULL; |
| 1458 GesturesProp* property = | 1459 GesturesProp* property = |
| 1459 new PROPTYPE(name, count, value, init, default_property); | 1460 new PROPTYPE(name, count, value, init, default_property); |
| 1460 | 1461 |
| 1461 // Start tracking the property in the provider. | 1462 // Start tracking the property in the provider. |
| 1462 PostCreateProperty(device_data, name, property); | 1463 PostCreateProperty(device_data, name, make_scoped_ptr(property)); |
| 1463 return property; | 1464 return property; |
| 1464 } | 1465 } |
| 1465 | 1466 |
| 1466 bool GesturesPropFunctionsWrapper::PreCreateProperty( | 1467 bool GesturesPropFunctionsWrapper::PreCreateProperty( |
| 1467 void* device_data, | 1468 void* device_data, |
| 1468 const char* name, | 1469 const char* name, |
| 1469 GesturesProp** default_property) { | 1470 GesturesProp** default_property) { |
| 1470 GesturePropertyProvider* provider = GetPropertyProvider(device_data); | 1471 GesturePropertyProvider* provider = GetPropertyProvider(device_data); |
| 1471 GesturePropertyProvider::DeviceId device_id = GetDeviceId(device_data); | 1472 GesturePropertyProvider::DeviceId device_id = GetDeviceId(device_data); |
| 1472 | 1473 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1484 LOG(WARNING) << "Gesture property \"" << name | 1485 LOG(WARNING) << "Gesture property \"" << name |
| 1485 << "\" re-created. This shouldn't happen at the normal usage."; | 1486 << "\" re-created. This shouldn't happen at the normal usage."; |
| 1486 Free(device_data, property); | 1487 Free(device_data, property); |
| 1487 } | 1488 } |
| 1488 | 1489 |
| 1489 // Return the found default property from conf files (could be NULL). | 1490 // Return the found default property from conf files (could be NULL). |
| 1490 *default_property = provider->GetDefaultProperty(device_id, name); | 1491 *default_property = provider->GetDefaultProperty(device_id, name); |
| 1491 return true; | 1492 return true; |
| 1492 } | 1493 } |
| 1493 | 1494 |
| 1494 void GesturesPropFunctionsWrapper::PostCreateProperty(void* device_data, | 1495 void GesturesPropFunctionsWrapper::PostCreateProperty( |
| 1495 const char* name, | 1496 void* device_data, |
| 1496 GesturesProp* property) { | 1497 const char* name, |
| 1498 scoped_ptr<GesturesProp> property) { |
| 1497 // Add the property to the gesture property provider. The gesture property | 1499 // Add the property to the gesture property provider. The gesture property |
| 1498 // provider will own it from now on. | 1500 // provider will own it from now on. |
| 1499 GesturePropertyProvider* provider = GetPropertyProvider(device_data); | 1501 GesturePropertyProvider* provider = GetPropertyProvider(device_data); |
| 1500 provider->AddProperty(GetDeviceId(device_data), name, property); | 1502 provider->AddProperty(GetDeviceId(device_data), name, std::move(property)); |
| 1501 | 1503 |
| 1502 // Log the creation. | 1504 // Log the creation. |
| 1503 DVLOG(3) << "Created active prop: " << *property; | 1505 DVLOG(3) << "Created active prop: " << *property; |
| 1504 } | 1506 } |
| 1505 | 1507 |
| 1506 GesturesProp* GesturesPropFunctionsWrapper::CreateIntSingle(void* device_data, | 1508 GesturesProp* GesturesPropFunctionsWrapper::CreateIntSingle(void* device_data, |
| 1507 const char* name, | 1509 const char* name, |
| 1508 int* value, | 1510 int* value, |
| 1509 int init) { | 1511 int init) { |
| 1510 return CreateInt(device_data, name, value, 1, &init); | 1512 return CreateInt(device_data, name, value, 1, &init); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 const GesturesPropProvider kGesturePropProvider = { | 1544 const GesturesPropProvider kGesturePropProvider = { |
| 1543 GesturesPropFunctionsWrapper::CreateInt, | 1545 GesturesPropFunctionsWrapper::CreateInt, |
| 1544 GesturesPropFunctionsWrapper::CreateShort, | 1546 GesturesPropFunctionsWrapper::CreateShort, |
| 1545 GesturesPropFunctionsWrapper::CreateBool, | 1547 GesturesPropFunctionsWrapper::CreateBool, |
| 1546 GesturesPropFunctionsWrapper::CreateString, | 1548 GesturesPropFunctionsWrapper::CreateString, |
| 1547 GesturesPropFunctionsWrapper::CreateReal, | 1549 GesturesPropFunctionsWrapper::CreateReal, |
| 1548 GesturesPropFunctionsWrapper::RegisterHandlers, | 1550 GesturesPropFunctionsWrapper::RegisterHandlers, |
| 1549 GesturesPropFunctionsWrapper::Free}; | 1551 GesturesPropFunctionsWrapper::Free}; |
| 1550 | 1552 |
| 1551 } // namespace ui | 1553 } // namespace ui |
| OLD | NEW |