OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/input_device_factory_evdev.h" | 5 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <linux/input.h> | 8 #include <linux/input.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 const base::FilePath& path = converter->path(); | 232 const base::FilePath& path = converter->path(); |
233 | 233 |
234 TRACE_EVENT1("evdev", "AttachInputDevice", "path", path.value()); | 234 TRACE_EVENT1("evdev", "AttachInputDevice", "path", path.value()); |
235 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 235 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
236 | 236 |
237 // If we have an existing device, detach it. We don't want two | 237 // If we have an existing device, detach it. We don't want two |
238 // devices with the same name open at the same time. | 238 // devices with the same name open at the same time. |
239 if (converters_[path]) | 239 if (converters_[path]) |
240 DetachInputDevice(path); | 240 DetachInputDevice(path); |
241 | 241 |
242 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | |
243 converter->HasPen()) | |
spang
2016/08/26 22:20:03
Please add braces when the body spans more than on
denniskempin
2016/08/26 23:02:07
Done.
| |
244 converter->SetPalmSuppressionCallback( | |
245 base::Bind(&InputDeviceFactoryEvdev::EnablePalmSuppression, | |
246 base::Unretained(this))); | |
247 | |
242 // Add initialized device to map. | 248 // Add initialized device to map. |
243 converters_[path] = converter.release(); | 249 converters_[path] = converter.release(); |
244 converters_[path]->Start(); | 250 converters_[path]->Start(); |
245 UpdateDirtyFlags(converters_[path]); | 251 UpdateDirtyFlags(converters_[path]); |
246 | 252 |
247 // Sync settings to new device. | 253 // Sync settings to new device. |
248 ApplyInputDeviceSettings(); | 254 ApplyInputDeviceSettings(); |
249 ApplyCapsLockLed(); | 255 ApplyCapsLockLed(); |
250 } | 256 } |
251 | 257 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 const EventConverterEvdev* converter) { | 375 const EventConverterEvdev* converter) { |
370 if (!input_device_settings_.enable_internal_touchpad && | 376 if (!input_device_settings_.enable_internal_touchpad && |
371 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | 377 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
372 converter->HasTouchpad()) | 378 converter->HasTouchpad()) |
373 return false; | 379 return false; |
374 | 380 |
375 if (!input_device_settings_.enable_touch_screens && | 381 if (!input_device_settings_.enable_touch_screens && |
376 converter->HasTouchscreen()) | 382 converter->HasTouchscreen()) |
377 return false; | 383 return false; |
378 | 384 |
385 if (palm_suppression_enabled_ && | |
386 converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | |
387 converter->HasTouchscreen() && !converter->HasPen()) | |
388 return false; | |
389 | |
379 return input_device_settings_.enable_devices; | 390 return input_device_settings_.enable_devices; |
380 } | 391 } |
381 | 392 |
382 void InputDeviceFactoryEvdev::UpdateDirtyFlags( | 393 void InputDeviceFactoryEvdev::UpdateDirtyFlags( |
383 const EventConverterEvdev* converter) { | 394 const EventConverterEvdev* converter) { |
384 if (converter->HasTouchscreen()) | 395 if (converter->HasTouchscreen()) |
385 touchscreen_list_dirty_ = true; | 396 touchscreen_list_dirty_ = true; |
386 | 397 |
387 if (converter->HasKeyboard()) | 398 if (converter->HasKeyboard()) |
388 keyboard_list_dirty_ = true; | 399 keyboard_list_dirty_ = true; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 #if defined(USE_EVDEV_GESTURES) | 495 #if defined(USE_EVDEV_GESTURES) |
485 std::vector<int> ids; | 496 std::vector<int> ids; |
486 gesture_property_provider_->GetDeviceIdsByType(type, &ids); | 497 gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
487 for (size_t i = 0; i < ids.size(); ++i) { | 498 for (size_t i = 0; i < ids.size(); ++i) { |
488 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, | 499 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, |
489 value); | 500 value); |
490 } | 501 } |
491 #endif | 502 #endif |
492 } | 503 } |
493 | 504 |
505 void InputDeviceFactoryEvdev::EnablePalmSuppression(bool enabled) { | |
506 if (enabled == palm_suppression_enabled_) | |
507 return; | |
508 palm_suppression_enabled_ = enabled; | |
509 | |
510 for (const auto& it : converters_) { | |
511 it.second->SetEnabled(IsDeviceEnabled(it.second)); | |
512 } | |
513 } | |
514 | |
494 } // namespace ui | 515 } // namespace ui |
OLD | NEW |