Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: ui/events/ozone/evdev/event_factory_evdev.cc

Issue 875513005: [PATCH 10/11] ozone: evdev: Add a device factory proxy that forwards to device thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/threading/worker_pool.h" 11 #include "base/threading/worker_pool.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "ui/events/devices/device_data_manager.h" 13 #include "ui/events/devices/device_data_manager.h"
14 #include "ui/events/devices/input_device.h" 14 #include "ui/events/devices/input_device.h"
15 #include "ui/events/ozone/device/device_event.h" 15 #include "ui/events/ozone/device/device_event.h"
16 #include "ui/events/ozone/device/device_manager.h" 16 #include "ui/events/ozone/device/device_manager.h"
17 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 17 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
18 #include "ui/events/ozone/evdev/input_controller_evdev.h" 18 #include "ui/events/ozone/evdev/input_controller_evdev.h"
19 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" 19 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
20 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h"
20 #include "ui/events/ozone/evdev/input_injector_evdev.h" 21 #include "ui/events/ozone/evdev/input_injector_evdev.h"
21 22
22 namespace ui { 23 namespace ui {
23 24
24 namespace { 25 namespace {
25 26
26 // Thread safe dispatcher proxy for EventFactoryEvdev. 27 // Thread safe dispatcher proxy for EventFactoryEvdev.
27 class ProxyDeviceEventDispatcher : public DeviceEventDispatcherEvdev { 28 class ProxyDeviceEventDispatcher : public DeviceEventDispatcherEvdev {
28 public: 29 public:
29 ProxyDeviceEventDispatcher( 30 ProxyDeviceEventDispatcher(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 void EventFactoryEvdev::Init() { 128 void EventFactoryEvdev::Init() {
128 DCHECK(!initialized_); 129 DCHECK(!initialized_);
129 130
130 // Set up device factory. 131 // Set up device factory.
131 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( 132 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher(
132 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), 133 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(),
133 weak_ptr_factory_.GetWeakPtr())); 134 weak_ptr_factory_.GetWeakPtr()));
134 input_device_factory_.reset( 135 input_device_factory_.reset(
135 new InputDeviceFactoryEvdev(dispatcher.Pass(), cursor_)); 136 new InputDeviceFactoryEvdev(dispatcher.Pass(), cursor_));
137 input_device_factory_proxy_.reset(
138 new InputDeviceFactoryEvdevProxy(base::ThreadTaskRunnerHandle::Get(),
139 input_device_factory_->GetWeakPtr()));
136 140
137 // TODO(spang): This settings interface is really broken. crbug.com/450899 141 // TODO(spang): This settings interface is really broken. crbug.com/450899
138 input_controller_.SetInputDeviceFactory(input_device_factory_.get()); 142 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get());
139 143
140 // Scan & monitor devices. 144 // Scan & monitor devices.
141 device_manager_->AddObserver(this); 145 device_manager_->AddObserver(this);
142 device_manager_->ScanDevices(this); 146 device_manager_->ScanDevices(this);
143 147
144 initialized_ = true; 148 initialized_ = true;
145 } 149 }
146 150
147 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { 151 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() {
148 // Use forwarding dispatcher for the injector rather than dispatching 152 // Use forwarding dispatcher for the injector rather than dispatching
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 276
273 277
274 void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { 278 void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) {
275 if (event.device_type() != DeviceEvent::INPUT) 279 if (event.device_type() != DeviceEvent::INPUT)
276 return; 280 return;
277 281
278 switch (event.action_type()) { 282 switch (event.action_type()) {
279 case DeviceEvent::ADD: 283 case DeviceEvent::ADD:
280 case DeviceEvent::CHANGE: { 284 case DeviceEvent::CHANGE: {
281 TRACE_EVENT1("ozone", "OnDeviceAdded", "path", event.path().value()); 285 TRACE_EVENT1("ozone", "OnDeviceAdded", "path", event.path().value());
282 input_device_factory_->AddInputDevice(NextDeviceId(), event.path()); 286 input_device_factory_proxy_->AddInputDevice(NextDeviceId(), event.path());
283 break; 287 break;
284 } 288 }
285 case DeviceEvent::REMOVE: { 289 case DeviceEvent::REMOVE: {
286 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value()); 290 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value());
287 input_device_factory_->RemoveInputDevice(event.path()); 291 input_device_factory_proxy_->RemoveInputDevice(event.path());
288 break; 292 break;
289 } 293 }
290 } 294 }
291 } 295 }
292 296
293 void EventFactoryEvdev::OnDispatcherListChanged() { 297 void EventFactoryEvdev::OnDispatcherListChanged() {
294 if (!initialized_) 298 if (!initialized_)
295 Init(); 299 Init();
296 } 300 }
297 301
298 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, 302 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
299 const gfx::PointF& location) { 303 const gfx::PointF& location) {
300 if (!cursor_) 304 if (!cursor_)
301 return; 305 return;
302 306
303 cursor_->MoveCursorTo(widget, location); 307 cursor_->MoveCursorTo(widget, location);
304 308
305 base::ThreadTaskRunnerHandle::Get()->PostTask( 309 base::ThreadTaskRunnerHandle::Get()->PostTask(
306 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, 310 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent,
307 weak_ptr_factory_.GetWeakPtr(), 311 weak_ptr_factory_.GetWeakPtr(),
308 MouseMoveEventParams(-1 /* device_id */, 312 MouseMoveEventParams(-1 /* device_id */,
309 cursor_->GetLocation()))); 313 cursor_->GetLocation())));
310 } 314 }
311 315
312 int EventFactoryEvdev::NextDeviceId() { 316 int EventFactoryEvdev::NextDeviceId() {
313 return ++last_device_id_; 317 return ++last_device_id_;
314 } 318 }
315 319
316 } // namespace ui 320 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.h ('k') | ui/events/ozone/evdev/input_controller_evdev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698