| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/task_runner.h" | 9 #include "base/task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 weak_ptr_factory_(this) { | 127 weak_ptr_factory_(this) { |
| 128 DCHECK(device_manager_); | 128 DCHECK(device_manager_); |
| 129 } | 129 } |
| 130 | 130 |
| 131 EventFactoryEvdev::~EventFactoryEvdev() { | 131 EventFactoryEvdev::~EventFactoryEvdev() { |
| 132 } | 132 } |
| 133 | 133 |
| 134 void EventFactoryEvdev::Init() { | 134 void EventFactoryEvdev::Init() { |
| 135 DCHECK(!initialized_); | 135 DCHECK(!initialized_); |
| 136 | 136 |
| 137 // Set up device factory. | 137 StartThread(); |
| 138 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( | |
| 139 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | |
| 140 weak_ptr_factory_.GetWeakPtr())); | |
| 141 input_device_factory_.reset( | |
| 142 new InputDeviceFactoryEvdev(dispatcher.Pass(), cursor_)); | |
| 143 input_device_factory_proxy_.reset( | |
| 144 new InputDeviceFactoryProxyEvdev(base::ThreadTaskRunnerHandle::Get(), | |
| 145 input_device_factory_->GetWeakPtr())); | |
| 146 | |
| 147 // TODO(spang): This settings interface is really broken. crbug.com/450899 | |
| 148 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); | |
| 149 | |
| 150 // Scan & monitor devices. | |
| 151 device_manager_->AddObserver(this); | |
| 152 device_manager_->ScanDevices(this); | |
| 153 | 138 |
| 154 initialized_ = true; | 139 initialized_ = true; |
| 155 } | 140 } |
| 156 | 141 |
| 157 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { | 142 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { |
| 158 return make_scoped_ptr(new InputInjectorEvdev( | 143 return make_scoped_ptr(new InputInjectorEvdev( |
| 159 &modifiers_, cursor_, &keyboard_, dispatch_callback_)); | 144 &modifiers_, cursor_, &keyboard_, dispatch_callback_)); |
| 160 } | 145 } |
| 161 | 146 |
| 162 void EventFactoryEvdev::DispatchKeyEvent(int device_id, | 147 void EventFactoryEvdev::DispatchKeyEvent(int device_id, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 cursor_->GetLocation(), | 305 cursor_->GetLocation(), |
| 321 modifiers_.GetModifierFlags(), | 306 modifiers_.GetModifierFlags(), |
| 322 /* changed_button_flags */ 0))); | 307 /* changed_button_flags */ 0))); |
| 323 } | 308 } |
| 324 } | 309 } |
| 325 | 310 |
| 326 int EventFactoryEvdev::NextDeviceId() { | 311 int EventFactoryEvdev::NextDeviceId() { |
| 327 return ++last_device_id_; | 312 return ++last_device_id_; |
| 328 } | 313 } |
| 329 | 314 |
| 315 void EventFactoryEvdev::StartThread() { |
| 316 // Set up device factory. |
| 317 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( |
| 318 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
| 319 weak_ptr_factory_.GetWeakPtr())); |
| 320 thread_.Start(dispatcher.Pass(), cursor_, |
| 321 base::Bind(&EventFactoryEvdev::OnThreadStarted, |
| 322 weak_ptr_factory_.GetWeakPtr())); |
| 323 } |
| 324 |
| 325 void EventFactoryEvdev::OnThreadStarted( |
| 326 scoped_ptr<InputDeviceFactoryProxyEvdev> input_device_factory) { |
| 327 input_device_factory_proxy_ = input_device_factory.Pass(); |
| 328 |
| 329 // TODO(spang): This settings interface is really broken. crbug.com/450899 |
| 330 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); |
| 331 |
| 332 // Scan & monitor devices. |
| 333 device_manager_->AddObserver(this); |
| 334 device_manager_->ScanDevices(this); |
| 335 } |
| 336 |
| 330 } // namespace ui | 337 } // namespace ui |
| OLD | NEW |