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 <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" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 // therefore should be run on a thread where latency is not critical. We | 123 // therefore should be run on a thread where latency is not critical. We |
124 // run it on the FILE thread. | 124 // run it on the FILE thread. |
125 void CloseInputDevice(const base::FilePath& path, | 125 void CloseInputDevice(const base::FilePath& path, |
126 scoped_ptr<EventConverterEvdev> converter) { | 126 scoped_ptr<EventConverterEvdev> converter) { |
127 TRACE_EVENT1("ozone", "CloseInputDevice", "path", path.value()); | 127 TRACE_EVENT1("ozone", "CloseInputDevice", "path", path.value()); |
128 converter.reset(); | 128 converter.reset(); |
129 } | 129 } |
130 | 130 |
131 } // namespace | 131 } // namespace |
132 | 132 |
133 EventFactoryEvdev::EventFactoryEvdev() | |
134 : device_manager_(NULL), | |
135 has_started_processing_events_(false), | |
136 ui_task_runner_(base::MessageLoopProxy::current()), | |
137 cursor_(NULL), | |
138 dispatch_callback_( | |
139 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), | |
140 base::Unretained(this))), | |
141 weak_ptr_factory_(this) {} | |
142 | |
143 EventFactoryEvdev::EventFactoryEvdev( | 133 EventFactoryEvdev::EventFactoryEvdev( |
144 CursorDelegateEvdev* cursor, | 134 CursorDelegateEvdev* cursor, |
145 DeviceManager* device_manager) | 135 DeviceManager* device_manager) |
146 : device_manager_(device_manager), | 136 : device_manager_(device_manager), |
147 has_started_processing_events_(false), | 137 has_started_processing_events_(false), |
148 ui_task_runner_(base::MessageLoopProxy::current()), | 138 ui_task_runner_(base::MessageLoopProxy::current()), |
149 cursor_(cursor), | 139 cursor_(cursor), |
150 dispatch_callback_( | 140 dispatch_callback_( |
151 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), | 141 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), |
152 base::Unretained(this))), | 142 base::Unretained(this))), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 base::WorkerPool::PostTask( | 213 base::WorkerPool::PostTask( |
224 FROM_HERE, | 214 FROM_HERE, |
225 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), | 215 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), |
226 true); | 216 true); |
227 } | 217 } |
228 } | 218 } |
229 | 219 |
230 void EventFactoryEvdev::StartProcessingEvents() { | 220 void EventFactoryEvdev::StartProcessingEvents() { |
231 CHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 221 CHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
232 | 222 |
233 if (device_manager_ && !has_started_processing_events_) { | 223 if (device_manager_ && !has_started_processing_events_) { |
dnicoara
2014/05/15 20:31:35
nit: I suppose device_manager_ should be removed f
sadrul
2014/05/16 03:11:51
I am including this in https://codereview.chromium
| |
234 has_started_processing_events_ = true; | 224 has_started_processing_events_ = true; |
235 // Scan & monitor devices. | 225 // Scan & monitor devices. |
236 device_manager_->AddObserver(this); | 226 device_manager_->AddObserver(this); |
237 device_manager_->ScanDevices(this); | 227 device_manager_->ScanDevices(this); |
238 } | 228 } |
239 } | 229 } |
240 | 230 |
241 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, | 231 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, |
242 const gfx::PointF& location) { | 232 const gfx::PointF& location) { |
243 if (cursor_) { | 233 if (cursor_) { |
244 cursor_->MoveCursorTo(widget, location); | 234 cursor_->MoveCursorTo(widget, location); |
245 MouseEvent mouse_event(ET_MOUSE_MOVED, | 235 MouseEvent mouse_event(ET_MOUSE_MOVED, |
246 cursor_->location(), | 236 cursor_->location(), |
247 cursor_->location(), | 237 cursor_->location(), |
248 modifiers_.GetModifierFlags(), | 238 modifiers_.GetModifierFlags(), |
249 /* changed_button_flags */ 0); | 239 /* changed_button_flags */ 0); |
250 DispatchEvent(&mouse_event); | 240 DispatchEvent(&mouse_event); |
251 } | 241 } |
252 } | 242 } |
253 | 243 |
254 } // namespace ui | 244 } // namespace ui |
OLD | NEW |