| 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/event_factory_evdev.h" | 5 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
| 11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 12 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 13 #include "ui/events/devices/device_data_manager.h" | 15 #include "ui/events/devices/device_data_manager.h" |
| 14 #include "ui/events/devices/input_device.h" | 16 #include "ui/events/devices/input_device.h" |
| 15 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
| 16 #include "ui/events/ozone/device/device_event.h" | 18 #include "ui/events/ozone/device/device_event.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 150 } |
| 149 | 151 |
| 150 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { | 152 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { |
| 151 // Use forwarding dispatcher for the injector rather than dispatching | 153 // Use forwarding dispatcher for the injector rather than dispatching |
| 152 // directly. We cannot assume it is safe to (re-)enter ui::Event dispatch | 154 // directly. We cannot assume it is safe to (re-)enter ui::Event dispatch |
| 153 // synchronously from the injection point. | 155 // synchronously from the injection point. |
| 154 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( | 156 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( |
| 155 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | 157 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
| 156 weak_ptr_factory_.GetWeakPtr())); | 158 weak_ptr_factory_.GetWeakPtr())); |
| 157 return make_scoped_ptr( | 159 return make_scoped_ptr( |
| 158 new InputInjectorEvdev(proxy_dispatcher.Pass(), cursor_)); | 160 new InputInjectorEvdev(std::move(proxy_dispatcher), cursor_)); |
| 159 } | 161 } |
| 160 | 162 |
| 161 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { | 163 void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) { |
| 162 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchKeyEvent", "device", | 164 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchKeyEvent", "device", |
| 163 params.device_id); | 165 params.device_id); |
| 164 keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat, | 166 keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat, |
| 165 params.timestamp, params.device_id); | 167 params.timestamp, params.device_id); |
| 166 } | 168 } |
| 167 | 169 |
| 168 void EventFactoryEvdev::DispatchMouseMoveEvent( | 170 void EventFactoryEvdev::DispatchMouseMoveEvent( |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 395 |
| 394 int EventFactoryEvdev::NextDeviceId() { | 396 int EventFactoryEvdev::NextDeviceId() { |
| 395 return ++last_device_id_; | 397 return ++last_device_id_; |
| 396 } | 398 } |
| 397 | 399 |
| 398 void EventFactoryEvdev::StartThread() { | 400 void EventFactoryEvdev::StartThread() { |
| 399 // Set up device factory. | 401 // Set up device factory. |
| 400 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( | 402 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( |
| 401 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | 403 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
| 402 weak_ptr_factory_.GetWeakPtr())); | 404 weak_ptr_factory_.GetWeakPtr())); |
| 403 thread_.Start(proxy_dispatcher.Pass(), cursor_, | 405 thread_.Start(std::move(proxy_dispatcher), cursor_, |
| 404 base::Bind(&EventFactoryEvdev::OnThreadStarted, | 406 base::Bind(&EventFactoryEvdev::OnThreadStarted, |
| 405 weak_ptr_factory_.GetWeakPtr())); | 407 weak_ptr_factory_.GetWeakPtr())); |
| 406 } | 408 } |
| 407 | 409 |
| 408 void EventFactoryEvdev::OnThreadStarted( | 410 void EventFactoryEvdev::OnThreadStarted( |
| 409 scoped_ptr<InputDeviceFactoryEvdevProxy> input_device_factory) { | 411 scoped_ptr<InputDeviceFactoryEvdevProxy> input_device_factory) { |
| 410 TRACE_EVENT0("evdev", "EventFactoryEvdev::OnThreadStarted"); | 412 TRACE_EVENT0("evdev", "EventFactoryEvdev::OnThreadStarted"); |
| 411 input_device_factory_proxy_ = input_device_factory.Pass(); | 413 input_device_factory_proxy_ = std::move(input_device_factory); |
| 412 | 414 |
| 413 // Hook up device configuration. | 415 // Hook up device configuration. |
| 414 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); | 416 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); |
| 415 | 417 |
| 416 // Scan & monitor devices. | 418 // Scan & monitor devices. |
| 417 device_manager_->AddObserver(this); | 419 device_manager_->AddObserver(this); |
| 418 device_manager_->ScanDevices(this); | 420 device_manager_->ScanDevices(this); |
| 419 | 421 |
| 420 // Notify device thread that initial scan is done. | 422 // Notify device thread that initial scan is done. |
| 421 input_device_factory_proxy_->OnStartupScanComplete(); | 423 input_device_factory_proxy_->OnStartupScanComplete(); |
| 422 } | 424 } |
| 423 | 425 |
| 424 } // namespace ui | 426 } // namespace ui |
| OLD | NEW |