| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 startup_devices_enumerated_ = true; | 200 startup_devices_enumerated_ = true; |
| 201 NotifyDevicesUpdated(); | 201 NotifyDevicesUpdated(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void InputDeviceFactoryEvdev::AttachInputDevice( | 204 void InputDeviceFactoryEvdev::AttachInputDevice( |
| 205 std::unique_ptr<EventConverterEvdev> converter) { | 205 std::unique_ptr<EventConverterEvdev> converter) { |
| 206 if (converter.get()) { | 206 if (converter.get()) { |
| 207 const base::FilePath& path = converter->path(); | 207 const base::FilePath& path = converter->path(); |
| 208 | 208 |
| 209 TRACE_EVENT1("evdev", "AttachInputDevice", "path", path.value()); | 209 TRACE_EVENT1("evdev", "AttachInputDevice", "path", path.value()); |
| 210 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 210 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 211 | 211 |
| 212 // If we have an existing device, detach it. We don't want two | 212 // If we have an existing device, detach it. We don't want two |
| 213 // devices with the same name open at the same time. | 213 // devices with the same name open at the same time. |
| 214 if (converters_[path]) | 214 if (converters_[path]) |
| 215 DetachInputDevice(path); | 215 DetachInputDevice(path); |
| 216 | 216 |
| 217 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && | 217 if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL && |
| 218 converter->HasPen()) { | 218 converter->HasPen()) { |
| 219 converter->SetPalmSuppressionCallback( | 219 converter->SetPalmSuppressionCallback( |
| 220 base::Bind(&InputDeviceFactoryEvdev::EnablePalmSuppression, | 220 base::Bind(&InputDeviceFactoryEvdev::EnablePalmSuppression, |
| 221 base::Unretained(this))); | 221 base::Unretained(this))); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Add initialized device to map. | 224 // Add initialized device to map. |
| 225 converters_[path] = std::move(converter); | 225 converters_[path] = std::move(converter); |
| 226 converters_[path]->Start(); | 226 converters_[path]->Start(); |
| 227 UpdateDirtyFlags(converters_[path].get()); | 227 UpdateDirtyFlags(converters_[path].get()); |
| 228 | 228 |
| 229 // Sync settings to new device. | 229 // Sync settings to new device. |
| 230 ApplyInputDeviceSettings(); | 230 ApplyInputDeviceSettings(); |
| 231 ApplyCapsLockLed(); | 231 ApplyCapsLockLed(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 --pending_device_changes_; | 234 --pending_device_changes_; |
| 235 NotifyDevicesUpdated(); | 235 NotifyDevicesUpdated(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { | 238 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { |
| 239 TRACE_EVENT1("evdev", "DetachInputDevice", "path", path.value()); | 239 TRACE_EVENT1("evdev", "DetachInputDevice", "path", path.value()); |
| 240 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 240 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 241 | 241 |
| 242 // Remove device from map. | 242 // Remove device from map. |
| 243 std::unique_ptr<EventConverterEvdev> converter = std::move(converters_[path]); | 243 std::unique_ptr<EventConverterEvdev> converter = std::move(converters_[path]); |
| 244 converters_.erase(path); | 244 converters_.erase(path); |
| 245 | 245 |
| 246 if (converter) { | 246 if (converter) { |
| 247 // Disable the device (to release keys/buttons/etc). | 247 // Disable the device (to release keys/buttons/etc). |
| 248 converter->SetEnabled(false); | 248 converter->SetEnabled(false); |
| 249 | 249 |
| 250 // Cancel libevent notifications from this converter. | 250 // Cancel libevent notifications from this converter. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 if (enabled == palm_suppression_enabled_) | 496 if (enabled == palm_suppression_enabled_) |
| 497 return; | 497 return; |
| 498 palm_suppression_enabled_ = enabled; | 498 palm_suppression_enabled_ = enabled; |
| 499 | 499 |
| 500 for (const auto& it : converters_) { | 500 for (const auto& it : converters_) { |
| 501 it.second->SetEnabled(IsDeviceEnabled(it.second.get())); | 501 it.second->SetEnabled(IsDeviceEnabled(it.second.get())); |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace ui | 505 } // namespace ui |
| OLD | NEW |