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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/task_runner.h" | 8 #include "base/task_runner.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 void EventFactoryEvdev::DispatchMouseMoveEvent( | 162 void EventFactoryEvdev::DispatchMouseMoveEvent( |
163 const MouseMoveEventParams& params) { | 163 const MouseMoveEventParams& params) { |
164 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseMoveEvent", "device", | 164 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseMoveEvent", "device", |
165 params.device_id); | 165 params.device_id); |
166 MouseEvent event(ui::ET_MOUSE_MOVED, params.location, params.location, | 166 MouseEvent event(ui::ET_MOUSE_MOVED, params.location, params.location, |
167 params.timestamp, modifiers_.GetModifierFlags(), | 167 params.timestamp, modifiers_.GetModifierFlags(), |
168 /* changed_button_flags */ 0); | 168 /* changed_button_flags */ 0); |
169 event.set_source_device_id(params.device_id); | 169 event.set_source_device_id(params.device_id); |
| 170 event.set_pointer_type(params.pointer_type); |
| 171 event.set_force(params.force); |
| 172 event.set_tilt_x(params.tilt_x); |
| 173 event.set_tilt_y(params.tilt_y); |
170 DispatchUiEvent(&event); | 174 DispatchUiEvent(&event); |
171 } | 175 } |
172 | 176 |
173 void EventFactoryEvdev::DispatchMouseButtonEvent( | 177 void EventFactoryEvdev::DispatchMouseButtonEvent( |
174 const MouseButtonEventParams& params) { | 178 const MouseButtonEventParams& params) { |
175 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", | 179 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", |
176 params.device_id); | 180 params.device_id); |
177 | 181 |
178 // Mouse buttons can be remapped, touchpad taps & clicks cannot. | 182 // Mouse buttons can be remapped, touchpad taps & clicks cannot. |
179 unsigned int button = params.button; | 183 unsigned int button = params.button; |
(...skipping 29 matching lines...) Expand all Loading... |
209 // Suppress nested clicks. EventModifiersEvdev counts presses, we only | 213 // Suppress nested clicks. EventModifiersEvdev counts presses, we only |
210 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. | 214 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. |
211 if (down == was_down) | 215 if (down == was_down) |
212 return; | 216 return; |
213 | 217 |
214 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, | 218 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
215 params.location, params.location, params.timestamp, | 219 params.location, params.location, params.timestamp, |
216 modifiers_.GetModifierFlags() | flag, | 220 modifiers_.GetModifierFlags() | flag, |
217 /* changed_button_flags */ flag); | 221 /* changed_button_flags */ flag); |
218 event.set_source_device_id(params.device_id); | 222 event.set_source_device_id(params.device_id); |
| 223 event.set_pointer_type(params.pointer_type); |
| 224 event.set_force(params.force); |
| 225 event.set_tilt_x(params.tilt_x); |
| 226 event.set_tilt_y(params.tilt_y); |
219 DispatchUiEvent(&event); | 227 DispatchUiEvent(&event); |
220 } | 228 } |
221 | 229 |
222 void EventFactoryEvdev::DispatchMouseWheelEvent( | 230 void EventFactoryEvdev::DispatchMouseWheelEvent( |
223 const MouseWheelEventParams& params) { | 231 const MouseWheelEventParams& params) { |
224 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", | 232 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", |
225 params.device_id); | 233 params.device_id); |
226 MouseWheelEvent event(params.delta, params.location, params.location, | 234 MouseWheelEvent event(params.delta, params.location, params.location, |
227 params.timestamp, modifiers_.GetModifierFlags(), | 235 params.timestamp, modifiers_.GetModifierFlags(), |
228 0 /* changed_button_flags */); | 236 0 /* changed_button_flags */); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, | 356 void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget, |
349 const gfx::PointF& location) { | 357 const gfx::PointF& location) { |
350 if (!cursor_) | 358 if (!cursor_) |
351 return; | 359 return; |
352 | 360 |
353 cursor_->MoveCursorTo(widget, location); | 361 cursor_->MoveCursorTo(widget, location); |
354 | 362 |
355 base::ThreadTaskRunnerHandle::Get()->PostTask( | 363 base::ThreadTaskRunnerHandle::Get()->PostTask( |
356 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, | 364 FROM_HERE, base::Bind(&EventFactoryEvdev::DispatchMouseMoveEvent, |
357 weak_ptr_factory_.GetWeakPtr(), | 365 weak_ptr_factory_.GetWeakPtr(), |
358 MouseMoveEventParams(-1 /* device_id */, | 366 MouseMoveEventParams( |
359 cursor_->GetLocation(), | 367 -1 /* device_id */, cursor_->GetLocation(), |
360 EventTimeForNow()))); | 368 EventPointerType::POINTER_TYPE_MOUSE, |
| 369 /* force */ 0.0f, /* tilt_x */ 0.0f, |
| 370 /* tilt_y */ 0.0f, EventTimeForNow()))); |
361 } | 371 } |
362 | 372 |
363 int EventFactoryEvdev::NextDeviceId() { | 373 int EventFactoryEvdev::NextDeviceId() { |
364 return ++last_device_id_; | 374 return ++last_device_id_; |
365 } | 375 } |
366 | 376 |
367 void EventFactoryEvdev::StartThread() { | 377 void EventFactoryEvdev::StartThread() { |
368 // Set up device factory. | 378 // Set up device factory. |
369 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( | 379 scoped_ptr<DeviceEventDispatcherEvdev> proxy_dispatcher( |
370 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), | 380 new ProxyDeviceEventDispatcher(base::ThreadTaskRunnerHandle::Get(), |
(...skipping 13 matching lines...) Expand all Loading... |
384 | 394 |
385 // Scan & monitor devices. | 395 // Scan & monitor devices. |
386 device_manager_->AddObserver(this); | 396 device_manager_->AddObserver(this); |
387 device_manager_->ScanDevices(this); | 397 device_manager_->ScanDevices(this); |
388 | 398 |
389 // Notify device thread that initial scan is done. | 399 // Notify device thread that initial scan is done. |
390 input_device_factory_proxy_->OnStartupScanComplete(); | 400 input_device_factory_proxy_->OnStartupScanComplete(); |
391 } | 401 } |
392 | 402 |
393 } // namespace ui | 403 } // namespace ui |
OLD | NEW |