| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 if (params.flags & EF_DIRECT_INPUT) { | 212 if (params.flags & EF_DIRECT_INPUT) { |
| 213 details = GetTransformedEventPointerDetails(params); | 213 details = GetTransformedEventPointerDetails(params); |
| 214 cursor_->MoveCursorTo(GetTransformedEventLocation(params)); | 214 cursor_->MoveCursorTo(GetTransformedEventLocation(params)); |
| 215 location = cursor_->GetLocation(); | 215 location = cursor_->GetLocation(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), | 218 MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 219 params.timestamp, | 219 params.timestamp, |
| 220 modifiers_.GetModifierFlags() | params.flags, | 220 modifiers_.GetModifierFlags() | params.flags, |
| 221 /* changed_button_flags */ 0); | 221 /* changed_button_flags */ 0, details); |
| 222 event.set_location_f(location); | 222 event.set_location_f(location); |
| 223 event.set_root_location_f(location); | 223 event.set_root_location_f(location); |
| 224 event.set_source_device_id(params.device_id); | 224 event.set_source_device_id(params.device_id); |
| 225 event.set_pointer_details(details); | |
| 226 DispatchUiEvent(&event); | 225 DispatchUiEvent(&event); |
| 227 } | 226 } |
| 228 | 227 |
| 229 void EventFactoryEvdev::DispatchMouseButtonEvent( | 228 void EventFactoryEvdev::DispatchMouseButtonEvent( |
| 230 const MouseButtonEventParams& params) { | 229 const MouseButtonEventParams& params) { |
| 231 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", | 230 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", |
| 232 params.device_id); | 231 params.device_id); |
| 233 | 232 |
| 234 gfx::PointF location = params.location; | 233 gfx::PointF location = params.location; |
| 235 PointerDetails details = params.pointer_details; | 234 PointerDetails details = params.pointer_details; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 bool down = modifiers_.GetModifierFlags() & flag; | 271 bool down = modifiers_.GetModifierFlags() & flag; |
| 273 | 272 |
| 274 // Suppress nested clicks. EventModifiersEvdev counts presses, we only | 273 // Suppress nested clicks. EventModifiersEvdev counts presses, we only |
| 275 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. | 274 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. |
| 276 if (down == was_down) | 275 if (down == was_down) |
| 277 return; | 276 return; |
| 278 | 277 |
| 279 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, | 278 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
| 280 gfx::Point(), gfx::Point(), params.timestamp, | 279 gfx::Point(), gfx::Point(), params.timestamp, |
| 281 modifiers_.GetModifierFlags() | flag | params.flags, | 280 modifiers_.GetModifierFlags() | flag | params.flags, |
| 282 /* changed_button_flags */ flag); | 281 /* changed_button_flags */ flag, details); |
| 283 event.set_location_f(location); | 282 event.set_location_f(location); |
| 284 event.set_root_location_f(location); | 283 event.set_root_location_f(location); |
| 285 event.set_source_device_id(params.device_id); | 284 event.set_source_device_id(params.device_id); |
| 286 event.set_pointer_details(details); | |
| 287 DispatchUiEvent(&event); | 285 DispatchUiEvent(&event); |
| 288 } | 286 } |
| 289 | 287 |
| 290 void EventFactoryEvdev::DispatchMouseWheelEvent( | 288 void EventFactoryEvdev::DispatchMouseWheelEvent( |
| 291 const MouseWheelEventParams& params) { | 289 const MouseWheelEventParams& params) { |
| 292 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", | 290 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", |
| 293 params.device_id); | 291 params.device_id); |
| 294 MouseWheelEvent event(params.delta, gfx::Point(), gfx::Point(), | 292 MouseWheelEvent event(params.delta, gfx::Point(), gfx::Point(), |
| 295 params.timestamp, modifiers_.GetModifierFlags(), | 293 params.timestamp, modifiers_.GetModifierFlags(), |
| 296 0 /* changed_button_flags */); | 294 0 /* changed_button_flags */); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 332 |
| 335 // params.slot is guaranteed to be < kNumTouchEvdevSlots. | 333 // params.slot is guaranteed to be < kNumTouchEvdevSlots. |
| 336 int touch_id = touch_id_generator_.GetGeneratedID( | 334 int touch_id = touch_id_generator_.GetGeneratedID( |
| 337 params.device_id * kNumTouchEvdevSlots + params.slot); | 335 params.device_id * kNumTouchEvdevSlots + params.slot); |
| 338 details.id = touch_id; | 336 details.id = touch_id; |
| 339 TouchEvent touch_event(params.type, gfx::Point(), params.timestamp, details, | 337 TouchEvent touch_event(params.type, gfx::Point(), params.timestamp, details, |
| 340 modifiers_.GetModifierFlags(), /* angle */ 0.f); | 338 modifiers_.GetModifierFlags(), /* angle */ 0.f); |
| 341 touch_event.set_location_f(location); | 339 touch_event.set_location_f(location); |
| 342 touch_event.set_root_location_f(location); | 340 touch_event.set_root_location_f(location); |
| 343 touch_event.set_source_device_id(params.device_id); | 341 touch_event.set_source_device_id(params.device_id); |
| 344 touch_event.set_pointer_details(details); | |
| 345 DispatchUiEvent(&touch_event); | 342 DispatchUiEvent(&touch_event); |
| 346 | 343 |
| 347 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) { | 344 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) { |
| 348 touch_id_generator_.ReleaseGeneratedID(touch_event.pointer_details().id); | 345 touch_id_generator_.ReleaseGeneratedID(touch_event.pointer_details().id); |
| 349 } | 346 } |
| 350 } | 347 } |
| 351 | 348 |
| 352 void EventFactoryEvdev::DispatchUiEvent(Event* event) { | 349 void EventFactoryEvdev::DispatchUiEvent(Event* event) { |
| 353 // DispatchEvent takes PlatformEvent which is void*. This function | 350 // DispatchEvent takes PlatformEvent which is void*. This function |
| 354 // wraps it with the real type. | 351 // wraps it with the real type. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 465 |
| 469 // Scan & monitor devices. | 466 // Scan & monitor devices. |
| 470 device_manager_->AddObserver(this); | 467 device_manager_->AddObserver(this); |
| 471 device_manager_->ScanDevices(this); | 468 device_manager_->ScanDevices(this); |
| 472 | 469 |
| 473 // Notify device thread that initial scan is done. | 470 // Notify device thread that initial scan is done. |
| 474 input_device_factory_proxy_->OnStartupScanComplete(); | 471 input_device_factory_proxy_->OnStartupScanComplete(); |
| 475 } | 472 } |
| 476 | 473 |
| 477 } // namespace ui | 474 } // namespace ui |
| OLD | NEW |