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

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

Issue 285303004: ozone: Remove the explicit call to start listening for events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.h ('k') | ui/events/ozone/event_factory_ozone.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 133 EventFactoryEvdev::EventFactoryEvdev(
134 CursorDelegateEvdev* cursor, 134 CursorDelegateEvdev* cursor,
135 DeviceManager* device_manager) 135 DeviceManager* device_manager)
136 : device_manager_(device_manager), 136 : device_manager_(device_manager),
137 has_started_processing_events_(false),
138 ui_task_runner_(base::MessageLoopProxy::current()), 137 ui_task_runner_(base::MessageLoopProxy::current()),
spang 2014/05/16 15:01:17 I think you need to remove this initializer.
sadrul 2014/05/16 16:34:14 Done.
139 cursor_(cursor), 138 cursor_(cursor),
140 dispatch_callback_( 139 dispatch_callback_(
141 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), 140 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent),
142 base::Unretained(this))), 141 base::Unretained(this))),
143 weak_ptr_factory_(this) {} 142 weak_ptr_factory_(this) {
143 CHECK(device_manager_);
144 }
144 145
145 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); } 146 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); }
146 147
147 void EventFactoryEvdev::DispatchUiEvent(Event* event) { 148 void EventFactoryEvdev::DispatchUiEvent(Event* event) {
148 DispatchEvent(event); 149 DispatchEvent(event);
149 } 150 }
150 151
151 void EventFactoryEvdev::AttachInputDevice( 152 void EventFactoryEvdev::AttachInputDevice(
152 const base::FilePath& path, 153 const base::FilePath& path,
153 scoped_ptr<EventConverterEvdev> converter) { 154 scoped_ptr<EventConverterEvdev> converter) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 break; 191 break;
191 case DeviceEvent::REMOVE: { 192 case DeviceEvent::REMOVE: {
192 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value()); 193 TRACE_EVENT1("ozone", "OnDeviceRemoved", "path", event.path().value());
193 DetachInputDevice(event.path()); 194 DetachInputDevice(event.path());
194 } 195 }
195 break; 196 break;
196 } 197 }
197 } 198 }
198 199
199 void EventFactoryEvdev::OnDispatcherListChanged() { 200 void EventFactoryEvdev::OnDispatcherListChanged() {
200 if (ui_task_runner_) 201 if (!ui_task_runner_) {
201 return; 202 ui_task_runner_ = base::MessageLoopProxy::current();
202 ui_task_runner_ = base::MessageLoopProxy::current(); 203 // Scan & monitor devices.
203 StartProcessingEvents(); 204 device_manager_->AddObserver(this);
205 device_manager_->ScanDevices(this);
206 }
204 } 207 }
205 208
206 void EventFactoryEvdev::DetachInputDevice(const base::FilePath& path) { 209 void EventFactoryEvdev::DetachInputDevice(const base::FilePath& path) {
207 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value()); 210 TRACE_EVENT1("ozone", "DetachInputDevice", "path", path.value());
208 CHECK(ui_task_runner_->RunsTasksOnCurrentThread()); 211 CHECK(ui_task_runner_->RunsTasksOnCurrentThread());
209 212
210 // Remove device from map. 213 // Remove device from map.
211 scoped_ptr<EventConverterEvdev> converter(converters_[path]); 214 scoped_ptr<EventConverterEvdev> converter(converters_[path]);
212 converters_.erase(path); 215 converters_.erase(path);
213 216
214 if (converter) { 217 if (converter) {
215 // Cancel libevent notifications from this converter. This part must be 218 // Cancel libevent notifications from this converter. This part must be
216 // on UI since the polling happens on UI. 219 // on UI since the polling happens on UI.
217 converter->Stop(); 220 converter->Stop();
218 221
219 // Dispatch task to close from the worker pool, since close may block. 222 // Dispatch task to close from the worker pool, since close may block.
220 base::WorkerPool::PostTask( 223 base::WorkerPool::PostTask(
221 FROM_HERE, 224 FROM_HERE,
222 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), 225 base::Bind(&CloseInputDevice, path, base::Passed(&converter)),
223 true); 226 true);
224 } 227 }
225 } 228 }
226 229
227 void EventFactoryEvdev::StartProcessingEvents() {
228 if (!ui_task_runner_)
229 return;
230 CHECK(ui_task_runner_->RunsTasksOnCurrentThread());
231
232 if (device_manager_ && !has_started_processing_events_) {
233 has_started_processing_events_ = true;
234 // Scan & monitor devices.
235 device_manager_->AddObserver(this);
236 device_manager_->ScanDevices(this);
237 }
238 }
239
240 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, 230 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
241 const gfx::PointF& location) { 231 const gfx::PointF& location) {
242 if (cursor_) { 232 if (cursor_) {
243 cursor_->MoveCursorTo(widget, location); 233 cursor_->MoveCursorTo(widget, location);
244 MouseEvent mouse_event(ET_MOUSE_MOVED, 234 MouseEvent mouse_event(ET_MOUSE_MOVED,
245 cursor_->location(), 235 cursor_->location(),
246 cursor_->location(), 236 cursor_->location(),
247 modifiers_.GetModifierFlags(), 237 modifiers_.GetModifierFlags(),
248 /* changed_button_flags */ 0); 238 /* changed_button_flags */ 0);
249 DispatchEvent(&mouse_event); 239 DispatchEvent(&mouse_event);
250 } 240 }
251 } 241 }
252 242
253 } // namespace ui 243 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.h ('k') | ui/events/ozone/event_factory_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698