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

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

Issue 250793005: Refactor Udev device support in Ozone and add a DRM hotplug monitor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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 | Annotate | Revision Log
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 <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/task_runner.h" 12 #include "base/task_runner.h"
13 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 13 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
14 #include "ui/events/ozone/evdev/device_manager_evdev.h" 14 #include "ui/events/ozone/evdev/device_manager_evdev.h"
15 #include "ui/events/ozone/evdev/event_device_info.h" 15 #include "ui/events/ozone/evdev/event_device_info.h"
16 #include "ui/events/ozone/evdev/key_event_converter_evdev.h" 16 #include "ui/events/ozone/evdev/key_event_converter_evdev.h"
17 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h" 17 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
18 18
19 #if defined(USE_UDEV)
20 #include "ui/events/ozone/evdev/device_manager_udev.h"
21 #endif
22
23 #if defined(USE_EVDEV_GESTURES) 19 #if defined(USE_EVDEV_GESTURES)
24 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h" 20 #include "ui/events/ozone/evdev/libgestures_glue/event_reader_libevdev_cros.h"
25 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h" 21 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr os.h"
26 #endif 22 #endif
27 23
28 #ifndef EVIOCSCLOCKID 24 #ifndef EVIOCSCLOCKID
29 #define EVIOCSCLOCKID _IOW('E', 0xa0, int) 25 #define EVIOCSCLOCKID _IOW('E', 0xa0, int)
30 #endif 26 #endif
31 27
32 namespace ui { 28 namespace ui {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 130
135 EventFactoryEvdev::EventFactoryEvdev() 131 EventFactoryEvdev::EventFactoryEvdev()
136 : ui_task_runner_(base::MessageLoopProxy::current()), 132 : ui_task_runner_(base::MessageLoopProxy::current()),
137 file_task_runner_(base::MessageLoopProxy::current()), 133 file_task_runner_(base::MessageLoopProxy::current()),
138 cursor_(NULL), 134 cursor_(NULL),
139 dispatch_callback_( 135 dispatch_callback_(
140 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), 136 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent),
141 base::Unretained(this))), 137 base::Unretained(this))),
142 weak_ptr_factory_(this) {} 138 weak_ptr_factory_(this) {}
143 139
144 EventFactoryEvdev::EventFactoryEvdev(CursorDelegateEvdev* cursor) 140 EventFactoryEvdev::EventFactoryEvdev(
145 : ui_task_runner_(base::MessageLoopProxy::current()), 141 CursorDelegateEvdev* cursor,
142 scoped_ptr<DeviceManagerEvdev> device_manager)
143 : device_manager_(device_manager.Pass()),
144 ui_task_runner_(base::MessageLoopProxy::current()),
146 file_task_runner_(base::MessageLoopProxy::current()), 145 file_task_runner_(base::MessageLoopProxy::current()),
147 cursor_(cursor), 146 cursor_(cursor),
148 dispatch_callback_( 147 dispatch_callback_(
149 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), 148 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent),
150 base::Unretained(this))), 149 base::Unretained(this))),
151 weak_ptr_factory_(this) {} 150 weak_ptr_factory_(this) {}
152 151
153 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); } 152 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); }
154 153
155 void EventFactoryEvdev::DispatchUiEvent(Event* event) { 154 void EventFactoryEvdev::DispatchUiEvent(Event* event) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 209 }
211 210
212 void EventFactoryEvdev::OnDeviceRemoved(const base::FilePath& path) { 211 void EventFactoryEvdev::OnDeviceRemoved(const base::FilePath& path) {
213 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", path.value()); 212 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", path.value());
214 DetachInputDevice(path); 213 DetachInputDevice(path);
215 } 214 }
216 215
217 void EventFactoryEvdev::StartProcessingEvents() { 216 void EventFactoryEvdev::StartProcessingEvents() {
218 CHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 217 CHECK(ui_task_runner_->RunsTasksOnCurrentThread());
219 218
220 #if defined(USE_UDEV) 219 if (device_manager_) {
221 // Scan for input devices using udev. 220 // Scan & monitor devices.
222 device_manager_ = CreateDeviceManagerUdev(); 221 device_manager_->ScanAndStartMonitoring(
223 #else 222 base::Bind(&EventFactoryEvdev::OnDeviceAdded, base::Unretained(this)),
224 // No udev support. Scan devices manually in /dev/input. 223 base::Bind(&EventFactoryEvdev::OnDeviceRemoved,
225 device_manager_ = CreateDeviceManagerManual(); 224 base::Unretained(this)));
226 #endif 225 }
227
228 // Scan & monitor devices.
229 device_manager_->ScanAndStartMonitoring(
230 base::Bind(&EventFactoryEvdev::OnDeviceAdded, base::Unretained(this)),
231 base::Bind(&EventFactoryEvdev::OnDeviceRemoved, base::Unretained(this)));
232 } 226 }
233 227
234 void EventFactoryEvdev::SetFileTaskRunner( 228 void EventFactoryEvdev::SetFileTaskRunner(
235 scoped_refptr<base::TaskRunner> task_runner) { 229 scoped_refptr<base::TaskRunner> task_runner) {
236 file_task_runner_ = task_runner; 230 file_task_runner_ = task_runner;
237 } 231 }
238 232
239 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, 233 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
240 const gfx::PointF& location) { 234 const gfx::PointF& location) {
241 if (cursor_) { 235 if (cursor_) {
242 cursor_->MoveCursorTo(widget, location); 236 cursor_->MoveCursorTo(widget, location);
243 MouseEvent mouse_event(ET_MOUSE_MOVED, 237 MouseEvent mouse_event(ET_MOUSE_MOVED,
244 cursor_->location(), 238 cursor_->location(),
245 cursor_->location(), 239 cursor_->location(),
246 modifiers_.GetModifierFlags(), 240 modifiers_.GetModifierFlags(),
247 /* changed_button_flags */ 0); 241 /* changed_button_flags */ 0);
248 DispatchEvent(&mouse_event); 242 DispatchEvent(&mouse_event);
249 } 243 }
250 } 244 }
251 245
252 } // namespace ui 246 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698