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

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: updates for events_unittests Created 5 years, 11 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 "ui/events/devices/device_data_manager.h" 12 #include "ui/events/devices/device_data_manager.h"
13 #include "ui/events/devices/input_device.h" 13 #include "ui/events/devices/input_device.h"
14 #include "ui/events/ozone/device/device_event.h" 14 #include "ui/events/ozone/device/device_event.h"
15 #include "ui/events/ozone/device/device_manager.h" 15 #include "ui/events/ozone/device/device_manager.h"
16 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 16 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
17 #include "ui/events/ozone/evdev/input_controller_evdev.h" 17 #include "ui/events/ozone/evdev/input_controller_evdev.h"
18 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" 18 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
19 #include "ui/events/ozone/evdev/input_device_factory_proxy_evdev.h"
19 #include "ui/events/ozone/evdev/input_injector_evdev.h" 20 #include "ui/events/ozone/evdev/input_injector_evdev.h"
20 21
21 namespace ui { 22 namespace ui {
22 23
23 namespace { 24 namespace {
24 25
25 class ForwardingDeviceEventDispatcher : public DeviceEventDispatcherEvdev { 26 class ForwardingDeviceEventDispatcher : public DeviceEventDispatcherEvdev {
26 public: 27 public:
27 ForwardingDeviceEventDispatcher( 28 ForwardingDeviceEventDispatcher(
28 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_runner, 29 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_runner,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 void EventFactoryEvdev::Init() { 134 void EventFactoryEvdev::Init() {
134 DCHECK(!initialized_); 135 DCHECK(!initialized_);
135 136
136 // Set up device factory. 137 // Set up device factory.
137 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher( 138 scoped_ptr<DeviceEventDispatcherEvdev> dispatcher(
138 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), 139 new ForwardingDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(),
139 weak_ptr_factory_.GetWeakPtr())); 140 weak_ptr_factory_.GetWeakPtr()));
140 input_device_factory_.reset( 141 input_device_factory_.reset(
141 new InputDeviceFactoryEvdev(dispatcher.Pass(), cursor_)); 142 new InputDeviceFactoryEvdev(dispatcher.Pass(), cursor_));
143 input_device_factory_proxy_.reset(
144 new InputDeviceFactoryProxyEvdev(base::ThreadTaskRunnerHandle::Get(),
145 input_device_factory_->GetWeakPtr()));
142 146
143 // TODO(spang): This settings interface is really broken. crbug.com/450899 147 // TODO(spang): This settings interface is really broken. crbug.com/450899
144 input_controller_.SetInputDeviceFactory(input_device_factory_.get()); 148 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get());
145 149
146 // Scan & monitor devices. 150 // Scan & monitor devices.
147 device_manager_->AddObserver(this); 151 device_manager_->AddObserver(this);
148 device_manager_->ScanDevices(this); 152 device_manager_->ScanDevices(this);
149 153
150 initialized_ = true; 154 initialized_ = true;
151 } 155 }
152 156
153 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() { 157 scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() {
154 return make_scoped_ptr(new InputInjectorEvdev( 158 return make_scoped_ptr(new InputInjectorEvdev(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 288 }
285 289
286 void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) { 290 void EventFactoryEvdev::OnDeviceEvent(const DeviceEvent& event) {
287 if (event.device_type() != DeviceEvent::INPUT) 291 if (event.device_type() != DeviceEvent::INPUT)
288 return; 292 return;
289 293
290 switch (event.action_type()) { 294 switch (event.action_type()) {
291 case DeviceEvent::ADD: 295 case DeviceEvent::ADD:
292 case DeviceEvent::CHANGE: { 296 case DeviceEvent::CHANGE: {
293 TRACE_EVENT1("ozone", "OnDeviceAdded", "path", event.path().value()); 297 TRACE_EVENT1("ozone", "OnDeviceAdded", "path", event.path().value());
294 input_device_factory_->AddInputDevice(NextDeviceId(), event.path()); 298 input_device_factory_proxy_->AddInputDevice(NextDeviceId(), event.path());
295 break; 299 break;
296 } 300 }
297 case DeviceEvent::REMOVE: { 301 case DeviceEvent::REMOVE: {
298 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value()); 302 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value());
299 input_device_factory_->RemoveInputDevice(event.path()); 303 input_device_factory_proxy_->RemoveInputDevice(event.path());
300 break; 304 break;
301 } 305 }
302 } 306 }
303 } 307 }
304 308
305 void EventFactoryEvdev::OnDispatcherListChanged() { 309 void EventFactoryEvdev::OnDispatcherListChanged() {
306 if (!initialized_) 310 if (!initialized_)
307 Init(); 311 Init();
308 } 312 }
309 313
310 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, 314 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
311 const gfx::PointF& location) { 315 const gfx::PointF& location) {
312 if (cursor_) { 316 if (cursor_) {
313 cursor_->MoveCursorTo(widget, location); 317 cursor_->MoveCursorTo(widget, location);
314 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED, 318 PostUiEvent(make_scoped_ptr(new MouseEvent(ET_MOUSE_MOVED,
315 cursor_->GetLocation(), 319 cursor_->GetLocation(),
316 cursor_->GetLocation(), 320 cursor_->GetLocation(),
317 modifiers_.GetModifierFlags(), 321 modifiers_.GetModifierFlags(),
318 /* changed_button_flags */ 0))); 322 /* changed_button_flags */ 0)));
319 } 323 }
320 } 324 }
321 325
322 int EventFactoryEvdev::NextDeviceId() { 326 int EventFactoryEvdev::NextDeviceId() {
323 return ++last_device_id_; 327 return ++last_device_id_;
324 } 328 }
325 329
326 } // namespace ui 330 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698