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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat, | 158 keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat, |
159 params.timestamp, params.device_id); | 159 params.timestamp, params.device_id); |
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 PointerEventDetails(EventPointerType::POINTER_TYPE_MOUSE)); |
169 event.set_source_device_id(params.device_id); | 170 event.set_source_device_id(params.device_id); |
170 DispatchUiEvent(&event); | 171 DispatchUiEvent(&event); |
171 } | 172 } |
172 | 173 |
173 void EventFactoryEvdev::DispatchMouseButtonEvent( | 174 void EventFactoryEvdev::DispatchMouseButtonEvent( |
174 const MouseButtonEventParams& params) { | 175 const MouseButtonEventParams& params) { |
175 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", | 176 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", |
176 params.device_id); | 177 params.device_id); |
177 | 178 |
178 // Mouse buttons can be remapped, touchpad taps & clicks cannot. | 179 // Mouse buttons can be remapped, touchpad taps & clicks cannot. |
(...skipping 28 matching lines...) Expand all Loading... |
207 bool down = modifiers_.GetModifierFlags() & flag; | 208 bool down = modifiers_.GetModifierFlags() & flag; |
208 | 209 |
209 // Suppress nested clicks. EventModifiersEvdev counts presses, we only | 210 // Suppress nested clicks. EventModifiersEvdev counts presses, we only |
210 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. | 211 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. |
211 if (down == was_down) | 212 if (down == was_down) |
212 return; | 213 return; |
213 | 214 |
214 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, | 215 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
215 params.location, params.location, params.timestamp, | 216 params.location, params.location, params.timestamp, |
216 modifiers_.GetModifierFlags() | flag, | 217 modifiers_.GetModifierFlags() | flag, |
217 /* changed_button_flags */ flag); | 218 /* changed_button_flags */ flag, |
| 219 PointerEventDetails(EventPointerType::POINTER_TYPE_MOUSE)); |
218 event.set_source_device_id(params.device_id); | 220 event.set_source_device_id(params.device_id); |
219 DispatchUiEvent(&event); | 221 DispatchUiEvent(&event); |
220 } | 222 } |
221 | 223 |
222 void EventFactoryEvdev::DispatchMouseWheelEvent( | 224 void EventFactoryEvdev::DispatchMouseWheelEvent( |
223 const MouseWheelEventParams& params) { | 225 const MouseWheelEventParams& params) { |
224 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", | 226 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", |
225 params.device_id); | 227 params.device_id); |
226 MouseWheelEvent event(params.delta, params.location, params.location, | 228 MouseWheelEvent event(params.delta, params.location, params.location, |
227 params.timestamp, modifiers_.GetModifierFlags(), | 229 params.timestamp, modifiers_.GetModifierFlags(), |
(...skipping 26 matching lines...) Expand all Loading... |
254 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x, | 256 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x, |
255 &y); | 257 &y); |
256 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, | 258 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, |
257 &radius_x); | 259 &radius_x); |
258 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, | 260 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, |
259 &radius_y); | 261 &radius_y); |
260 | 262 |
261 // params.slot is guaranteed to be < kNumTouchEvdevSlots. | 263 // params.slot is guaranteed to be < kNumTouchEvdevSlots. |
262 int touch_id = touch_id_generator_.GetGeneratedID( | 264 int touch_id = touch_id_generator_.GetGeneratedID( |
263 params.device_id * kNumTouchEvdevSlots + params.slot); | 265 params.device_id * kNumTouchEvdevSlots + params.slot); |
264 TouchEvent touch_event(params.type, gfx::PointF(x, y), | 266 TouchEvent touch_event( |
265 modifiers_.GetModifierFlags(), touch_id, | 267 params.type, gfx::PointF(x, y), modifiers_.GetModifierFlags(), touch_id, |
266 params.timestamp, radius_x, radius_y, | 268 params.timestamp, /* angle */ 0.f, |
267 /* angle */ 0.f, params.pressure); | 269 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, radius_x, |
| 270 radius_y, params.pressure, /* tilt_x */ 0.f, |
| 271 /* tilt_y */ 0.f)); |
268 touch_event.set_source_device_id(params.device_id); | 272 touch_event.set_source_device_id(params.device_id); |
269 DispatchUiEvent(&touch_event); | 273 DispatchUiEvent(&touch_event); |
270 | 274 |
271 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) { | 275 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) { |
272 touch_id_generator_.ReleaseGeneratedID(touch_event.touch_id()); | 276 touch_id_generator_.ReleaseGeneratedID(touch_event.touch_id()); |
273 } | 277 } |
274 } | 278 } |
275 | 279 |
276 void EventFactoryEvdev::DispatchUiEvent(Event* event) { | 280 void EventFactoryEvdev::DispatchUiEvent(Event* event) { |
277 // DispatchEvent takes PlatformEvent which is void*. This function | 281 // DispatchEvent takes PlatformEvent which is void*. This function |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 388 |
385 // Scan & monitor devices. | 389 // Scan & monitor devices. |
386 device_manager_->AddObserver(this); | 390 device_manager_->AddObserver(this); |
387 device_manager_->ScanDevices(this); | 391 device_manager_->ScanDevices(this); |
388 | 392 |
389 // Notify device thread that initial scan is done. | 393 // Notify device thread that initial scan is done. |
390 input_device_factory_proxy_->OnStartupScanComplete(); | 394 input_device_factory_proxy_->OnStartupScanComplete(); |
391 } | 395 } |
392 | 396 |
393 } // namespace ui | 397 } // namespace ui |
OLD | NEW |