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

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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() 133 EventFactoryEvdev::EventFactoryEvdev()
134 : device_manager_(NULL), 134 : device_manager_(NULL),
135 has_started_processing_events_(false),
136 ui_task_runner_(base::MessageLoopProxy::current()), 135 ui_task_runner_(base::MessageLoopProxy::current()),
137 cursor_(NULL), 136 cursor_(NULL),
138 dispatch_callback_( 137 dispatch_callback_(
139 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), 138 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent),
140 base::Unretained(this))), 139 base::Unretained(this))),
141 weak_ptr_factory_(this) {} 140 weak_ptr_factory_(this) {}
142 141
143 EventFactoryEvdev::EventFactoryEvdev( 142 EventFactoryEvdev::EventFactoryEvdev(
144 CursorDelegateEvdev* cursor, 143 CursorDelegateEvdev* cursor,
145 DeviceManager* device_manager) 144 DeviceManager* device_manager)
146 : device_manager_(device_manager), 145 : device_manager_(device_manager),
147 has_started_processing_events_(false),
148 ui_task_runner_(base::MessageLoopProxy::current()), 146 ui_task_runner_(base::MessageLoopProxy::current()),
149 cursor_(cursor), 147 cursor_(cursor),
150 dispatch_callback_( 148 dispatch_callback_(
151 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent), 149 base::Bind(base::IgnoreResult(&EventFactoryEvdev::DispatchUiEvent),
152 base::Unretained(this))), 150 base::Unretained(this))),
153 weak_ptr_factory_(this) {} 151 weak_ptr_factory_(this) {
152 if (device_manager_) {
153 // Scan & monitor devices.
154 device_manager_->AddObserver(this);
155 device_manager_->ScanDevices(this);
sadrul 2014/05/15 16:30:04 I am not sure if this depends on other parts of th
156 }
157 }
154 158
155 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); } 159 EventFactoryEvdev::~EventFactoryEvdev() { STLDeleteValues(&converters_); }
156 160
157 void EventFactoryEvdev::DispatchUiEvent(Event* event) { 161 void EventFactoryEvdev::DispatchUiEvent(Event* event) {
158 DispatchEvent(event); 162 DispatchEvent(event);
159 } 163 }
160 164
161 void EventFactoryEvdev::AttachInputDevice( 165 void EventFactoryEvdev::AttachInputDevice(
162 const base::FilePath& path, 166 const base::FilePath& path,
163 scoped_ptr<EventConverterEvdev> converter) { 167 scoped_ptr<EventConverterEvdev> converter) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 converter->Stop(); 224 converter->Stop();
221 225
222 // Dispatch task to close from the worker pool, since close may block. 226 // Dispatch task to close from the worker pool, since close may block.
223 base::WorkerPool::PostTask( 227 base::WorkerPool::PostTask(
224 FROM_HERE, 228 FROM_HERE,
225 base::Bind(&CloseInputDevice, path, base::Passed(&converter)), 229 base::Bind(&CloseInputDevice, path, base::Passed(&converter)),
226 true); 230 true);
227 } 231 }
228 } 232 }
229 233
230 void EventFactoryEvdev::StartProcessingEvents() {
231 CHECK(ui_task_runner_->RunsTasksOnCurrentThread());
232
233 if (device_manager_ && !has_started_processing_events_) {
234 has_started_processing_events_ = true;
235 // Scan & monitor devices.
236 device_manager_->AddObserver(this);
237 device_manager_->ScanDevices(this);
238 }
239 }
240
241 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, 234 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
242 const gfx::PointF& location) { 235 const gfx::PointF& location) {
243 if (cursor_) { 236 if (cursor_) {
244 cursor_->MoveCursorTo(widget, location); 237 cursor_->MoveCursorTo(widget, location);
245 MouseEvent mouse_event(ET_MOUSE_MOVED, 238 MouseEvent mouse_event(ET_MOUSE_MOVED,
246 cursor_->location(), 239 cursor_->location(),
247 cursor_->location(), 240 cursor_->location(),
248 modifiers_.GetModifierFlags(), 241 modifiers_.GetModifierFlags(),
249 /* changed_button_flags */ 0); 242 /* changed_button_flags */ 0);
250 DispatchEvent(&mouse_event); 243 DispatchEvent(&mouse_event);
251 } 244 }
252 } 245 }
253 246
254 } // namespace ui 247 } // 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