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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 weak_ptr_factory_(this) { | 119 weak_ptr_factory_(this) { |
120 DCHECK(device_manager_); | 120 DCHECK(device_manager_); |
121 } | 121 } |
122 | 122 |
123 EventFactoryEvdev::~EventFactoryEvdev() { | 123 EventFactoryEvdev::~EventFactoryEvdev() { |
124 } | 124 } |
125 | 125 |
126 void EventFactoryEvdev::Init() { | 126 void EventFactoryEvdev::Init() { |
127 DCHECK(!initialized_); | 127 DCHECK(!initialized_); |
128 | 128 |
129 // Set up device factory. | 129 StartThread(); |
130 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( | |
131 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | |
132 weak_ptr_factory_.GetWeakPtr())); | |
133 input_device_factory_.reset( | |
134 new InputDeviceFactoryEvdev(dispatcher.Pass(), cursor_)); | |
135 input_device_factory_proxy_.reset( | |
136 new InputDeviceFactoryProxyEvdev(base::ThreadTaskRunnerHandle::Get(), | |
137 input_device_factory_->GetWeakPtr())); | |
138 | |
139 // TODO(spang): This settings interface is really broken. crbug.com/450899 | |
140 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); | |
141 | |
142 // Scan & monitor devices. | |
143 device_manager_->AddObserver(this); | |
144 device_manager_->ScanDevices(this); | |
145 | 130 |
146 initialized_ = true; | 131 initialized_ = true; |
147 } | 132 } |
148 | 133 |
149 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { | 134 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { |
150 // Use forwarding dispatcher for the injector rather than dispatching | 135 // Use forwarding dispatcher for the injector rather than dispatching |
151 // directly. We cannot assume it is safe to (re-)enter ui::Event dispatch | 136 // directly. We cannot assume it is safe to (re-)enter ui::Event dispatch |
152 // synchronously from the injection point. | 137 // synchronously from the injection point. |
153 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( | 138 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( |
154 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | 139 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, | 290 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, |
306 weak_ptr_factory_.GetWeakPtr(), | 291 weak_ptr_factory_.GetWeakPtr(), |
307 MouseMoveEventParams(-1 /* device_id */, | 292 MouseMoveEventParams(-1 /* device_id */, |
308 cursor_->GetLocation()))); | 293 cursor_->GetLocation()))); |
309 } | 294 } |
310 | 295 |
311 int EventFactoryEvdev::NextDeviceId() { | 296 int EventFactoryEvdev::NextDeviceId() { |
312 return ++last_device_id_; | 297 return ++last_device_id_; |
313 } | 298 } |
314 | 299 |
300 void EventFactoryEvdev::StartThread() { | |
301 // Set up device factory. | |
302 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( | |
alexst (slow to review)
2015/01/28 21:06:12
per comments in previous patches, can this be disp
spang
2015/01/28 21:37:32
Done.
| |
303 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | |
304 weak_ptr_factory_.GetWeakPtr())); | |
305 thread_.Start(dispatcher.Pass(), cursor_, | |
306 base::Bind(&EventFactoryEvdev::OnThreadStarted, | |
307 weak_ptr_factory_.GetWeakPtr())); | |
308 } | |
309 | |
310 void EventFactoryEvdev::OnThreadStarted( | |
311 scoped_ptr<InputDeviceFactoryProxyEvdev> input_device_factory) { | |
312 input_device_factory_proxy_ = input_device_factory.Pass(); | |
313 | |
314 // TODO(spang): This settings interface is really broken. crbug.com/450899 | |
315 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); | |
316 | |
317 // Scan & monitor devices. | |
318 device_manager_->AddObserver(this); | |
319 device_manager_->ScanDevices(this); | |
320 } | |
321 | |
315 } // namespace ui | 322 } // namespace ui |
OLD | NEW |