| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchKeyEvent", "device", | 162 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchKeyEvent", "device", |
| 163 params.device_id); | 163 params.device_id); |
| 164 keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat, | 164 keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat, |
| 165 params.timestamp, params.device_id); | 165 params.timestamp, params.device_id); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void EventFactoryEvdev::DispatchMouseMoveEvent( | 168 void EventFactoryEvdev::DispatchMouseMoveEvent( |
| 169 const MouseMoveEventParams& params) { | 169 const MouseMoveEventParams& params) { |
| 170 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseMoveEvent", "device", | 170 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseMoveEvent", "device", |
| 171 params.device_id); | 171 params.device_id); |
| 172 MouseEvent event(ui::ET_MOUSE_MOVED, params.location, params.location, | 172 MouseEvent event(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), |
| 173 params.timestamp, modifiers_.GetModifierFlags(), | 173 params.timestamp, modifiers_.GetModifierFlags(), |
| 174 /* changed_button_flags */ 0); | 174 /* changed_button_flags */ 0); |
| 175 event.set_location_f(params.location); |
| 176 event.set_root_location_f(params.location); |
| 175 event.set_source_device_id(params.device_id); | 177 event.set_source_device_id(params.device_id); |
| 176 event.set_pointer_details(params.pointer_details); | 178 event.set_pointer_details(params.pointer_details); |
| 177 DispatchUiEvent(&event); | 179 DispatchUiEvent(&event); |
| 178 } | 180 } |
| 179 | 181 |
| 180 void EventFactoryEvdev::DispatchMouseButtonEvent( | 182 void EventFactoryEvdev::DispatchMouseButtonEvent( |
| 181 const MouseButtonEventParams& params) { | 183 const MouseButtonEventParams& params) { |
| 182 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", | 184 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseButtonEvent", "device", |
| 183 params.device_id); | 185 params.device_id); |
| 184 | 186 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 212 bool was_down = modifiers_.GetModifierFlags() & flag; | 214 bool was_down = modifiers_.GetModifierFlags() & flag; |
| 213 modifiers_.UpdateModifier(modifier, params.down); | 215 modifiers_.UpdateModifier(modifier, params.down); |
| 214 bool down = modifiers_.GetModifierFlags() & flag; | 216 bool down = modifiers_.GetModifierFlags() & flag; |
| 215 | 217 |
| 216 // Suppress nested clicks. EventModifiersEvdev counts presses, we only | 218 // Suppress nested clicks. EventModifiersEvdev counts presses, we only |
| 217 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. | 219 // dispatch an event on 0-1 (first press) and 1-0 (last release) transitions. |
| 218 if (down == was_down) | 220 if (down == was_down) |
| 219 return; | 221 return; |
| 220 | 222 |
| 221 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, | 223 MouseEvent event(params.down ? ui::ET_MOUSE_PRESSED : ui::ET_MOUSE_RELEASED, |
| 222 params.location, params.location, params.timestamp, | 224 gfx::Point(), gfx::Point(), params.timestamp, |
| 223 modifiers_.GetModifierFlags() | flag, | 225 modifiers_.GetModifierFlags() | flag, |
| 224 /* changed_button_flags */ flag); | 226 /* changed_button_flags */ flag); |
| 227 event.set_location_f(params.location); |
| 228 event.set_root_location_f(params.location); |
| 225 event.set_source_device_id(params.device_id); | 229 event.set_source_device_id(params.device_id); |
| 226 event.set_pointer_details(params.pointer_details); | 230 event.set_pointer_details(params.pointer_details); |
| 227 DispatchUiEvent(&event); | 231 DispatchUiEvent(&event); |
| 228 } | 232 } |
| 229 | 233 |
| 230 void EventFactoryEvdev::DispatchMouseWheelEvent( | 234 void EventFactoryEvdev::DispatchMouseWheelEvent( |
| 231 const MouseWheelEventParams& params) { | 235 const MouseWheelEventParams& params) { |
| 232 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", | 236 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchMouseWheelEvent", "device", |
| 233 params.device_id); | 237 params.device_id); |
| 234 MouseWheelEvent event(params.delta, params.location, params.location, | 238 MouseWheelEvent event(params.delta, gfx::Point(), gfx::Point(), |
| 235 params.timestamp, modifiers_.GetModifierFlags(), | 239 params.timestamp, modifiers_.GetModifierFlags(), |
| 236 0 /* changed_button_flags */); | 240 0 /* changed_button_flags */); |
| 241 event.set_location_f(params.location); |
| 242 event.set_root_location_f(params.location); |
| 237 event.set_source_device_id(params.device_id); | 243 event.set_source_device_id(params.device_id); |
| 238 DispatchUiEvent(&event); | 244 DispatchUiEvent(&event); |
| 239 } | 245 } |
| 240 | 246 |
| 241 void EventFactoryEvdev::DispatchPinchEvent(const PinchEventParams& params) { | 247 void EventFactoryEvdev::DispatchPinchEvent(const PinchEventParams& params) { |
| 242 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchPinchEvent", "device", | 248 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchPinchEvent", "device", |
| 243 params.device_id); | 249 params.device_id); |
| 244 GestureEventDetails details(params.type); | 250 GestureEventDetails details(params.type); |
| 245 details.set_scale(params.scale); | 251 details.set_scale(params.scale); |
| 246 GestureEvent event(params.location.x(), params.location.y(), 0, | 252 GestureEvent event(params.location.x(), params.location.y(), 0, |
| 247 params.timestamp, details); | 253 params.timestamp, details); |
| 248 event.set_source_device_id(params.device_id); | 254 event.set_source_device_id(params.device_id); |
| 249 DispatchUiEvent(&event); | 255 DispatchUiEvent(&event); |
| 250 } | 256 } |
| 251 | 257 |
| 252 void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) { | 258 void EventFactoryEvdev::DispatchScrollEvent(const ScrollEventParams& params) { |
| 253 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchScrollEvent", "device", | 259 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchScrollEvent", "device", |
| 254 params.device_id); | 260 params.device_id); |
| 255 ScrollEvent event(params.type, params.location, params.timestamp, | 261 ScrollEvent event(params.type, gfx::Point(), params.timestamp, |
| 256 modifiers_.GetModifierFlags(), params.delta.x(), | 262 modifiers_.GetModifierFlags(), params.delta.x(), |
| 257 params.delta.y(), params.ordinal_delta.x(), | 263 params.delta.y(), params.ordinal_delta.x(), |
| 258 params.ordinal_delta.y(), params.finger_count); | 264 params.ordinal_delta.y(), params.finger_count); |
| 265 event.set_location_f(params.location); |
| 266 event.set_root_location_f(params.location); |
| 259 event.set_source_device_id(params.device_id); | 267 event.set_source_device_id(params.device_id); |
| 260 DispatchUiEvent(&event); | 268 DispatchUiEvent(&event); |
| 261 } | 269 } |
| 262 | 270 |
| 263 void EventFactoryEvdev::DispatchTouchEvent(const TouchEventParams& params) { | 271 void EventFactoryEvdev::DispatchTouchEvent(const TouchEventParams& params) { |
| 264 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchTouchEvent", "device", | 272 TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchTouchEvent", "device", |
| 265 params.device_id); | 273 params.device_id); |
| 266 | 274 |
| 267 float x = params.location.x(); | 275 float x = params.location.x(); |
| 268 float y = params.location.y(); | 276 float y = params.location.y(); |
| 269 double radius_x = params.radii.x(); | 277 double radius_x = params.radii.x(); |
| 270 double radius_y = params.radii.y(); | 278 double radius_y = params.radii.y(); |
| 271 | 279 |
| 272 // Transform the event to align touches to the image based on display mode. | 280 // Transform the event to align touches to the image based on display mode. |
| 273 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x, | 281 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x, |
| 274 &y); | 282 &y); |
| 275 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, | 283 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, |
| 276 &radius_x); | 284 &radius_x); |
| 277 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, | 285 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, |
| 278 &radius_y); | 286 &radius_y); |
| 279 | 287 |
| 280 // params.slot is guaranteed to be < kNumTouchEvdevSlots. | 288 // params.slot is guaranteed to be < kNumTouchEvdevSlots. |
| 281 int touch_id = touch_id_generator_.GetGeneratedID( | 289 int touch_id = touch_id_generator_.GetGeneratedID( |
| 282 params.device_id * kNumTouchEvdevSlots + params.slot); | 290 params.device_id * kNumTouchEvdevSlots + params.slot); |
| 283 TouchEvent touch_event(params.type, gfx::PointF(x, y), | 291 TouchEvent touch_event(params.type, gfx::Point(), |
| 284 modifiers_.GetModifierFlags(), touch_id, | 292 modifiers_.GetModifierFlags(), touch_id, |
| 285 params.timestamp, radius_x, radius_y, | 293 params.timestamp, radius_x, radius_y, |
| 286 /* angle */ 0.f, params.pressure); | 294 /* angle */ 0.f, params.pressure); |
| 295 touch_event.set_location_f(gfx::PointF(x, y)); |
| 296 touch_event.set_root_location_f(gfx::PointF(x, y)); |
| 287 touch_event.set_source_device_id(params.device_id); | 297 touch_event.set_source_device_id(params.device_id); |
| 288 DispatchUiEvent(&touch_event); | 298 DispatchUiEvent(&touch_event); |
| 289 | 299 |
| 290 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) { | 300 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) { |
| 291 touch_id_generator_.ReleaseGeneratedID(touch_event.touch_id()); | 301 touch_id_generator_.ReleaseGeneratedID(touch_event.touch_id()); |
| 292 } | 302 } |
| 293 } | 303 } |
| 294 | 304 |
| 295 void EventFactoryEvdev::DispatchUiEvent(Event* event) { | 305 void EventFactoryEvdev::DispatchUiEvent(Event* event) { |
| 296 // DispatchEvent takes PlatformEvent which is void*. This function | 306 // DispatchEvent takes PlatformEvent which is void*. This function |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 415 |
| 406 // Scan & monitor devices. | 416 // Scan & monitor devices. |
| 407 device_manager_->AddObserver(this); | 417 device_manager_->AddObserver(this); |
| 408 device_manager_->ScanDevices(this); | 418 device_manager_->ScanDevices(this); |
| 409 | 419 |
| 410 // Notify device thread that initial scan is done. | 420 // Notify device thread that initial scan is done. |
| 411 input_device_factory_proxy_->OnStartupScanComplete(); | 421 input_device_factory_proxy_->OnStartupScanComplete(); |
| 412 } | 422 } |
| 413 | 423 |
| 414 } // namespace ui | 424 } // namespace ui |
| OLD | NEW |