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

Side by Side Diff: ui/events/ozone/evdev/event_factory_evdev.cc

Issue 1048333005: ozone: Map TouchEvent::touch_id_ into expected range (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Push all touch id management into EventFactoryEvdev Created 5 years, 8 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
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 "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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "ui/events/devices/device_data_manager.h" 13 #include "ui/events/devices/device_data_manager.h"
14 #include "ui/events/devices/input_device.h" 14 #include "ui/events/devices/input_device.h"
15 #include "ui/events/event_utils.h" 15 #include "ui/events/event_utils.h"
16 #include "ui/events/ozone/device/device_event.h" 16 #include "ui/events/ozone/device/device_event.h"
17 #include "ui/events/ozone/device/device_manager.h" 17 #include "ui/events/ozone/device/device_manager.h"
18 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 18 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
19 #include "ui/events/ozone/evdev/input_controller_evdev.h" 19 #include "ui/events/ozone/evdev/input_controller_evdev.h"
20 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" 20 #include "ui/events/ozone/evdev/input_device_factory_evdev.h"
21 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h" 21 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h"
22 #include "ui/events/ozone/evdev/input_injector_evdev.h" 22 #include "ui/events/ozone/evdev/input_injector_evdev.h"
23 #include "ui/events/ozone/evdev/touch_evdev_types.h"
23 24
24 namespace ui { 25 namespace ui {
25 26
26 namespace { 27 namespace {
27 28
28 // Thread safe dispatcher proxy for EventFactoryEvdev. 29 // Thread safe dispatcher proxy for EventFactoryEvdev.
29 // 30 //
30 // This is used on the device I/O thread for dispatching to UI. 31 // This is used on the device I/O thread for dispatching to UI.
31 class ProxyDeviceEventDispatcher : public DeviceEventDispatcherEvdev { 32 class ProxyDeviceEventDispatcher : public DeviceEventDispatcherEvdev {
32 public: 33 public:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 KeyboardLayoutEngine* keyboard_layout) 115 KeyboardLayoutEngine* keyboard_layout)
115 : last_device_id_(0), 116 : last_device_id_(0),
116 device_manager_(device_manager), 117 device_manager_(device_manager),
117 keyboard_(&modifiers_, 118 keyboard_(&modifiers_,
118 keyboard_layout, 119 keyboard_layout,
119 base::Bind(&EventFactoryEvdev::DispatchUiEvent, 120 base::Bind(&EventFactoryEvdev::DispatchUiEvent,
120 base::Unretained(this))), 121 base::Unretained(this))),
121 cursor_(cursor), 122 cursor_(cursor),
122 input_controller_(&keyboard_, &button_map_), 123 input_controller_(&keyboard_, &button_map_),
123 initialized_(false), 124 initialized_(false),
125 touch_id_generator_(0),
124 weak_ptr_factory_(this) { 126 weak_ptr_factory_(this) {
125 DCHECK(device_manager_); 127 DCHECK(device_manager_);
126 } 128 }
127 129
128 EventFactoryEvdev::~EventFactoryEvdev() { 130 EventFactoryEvdev::~EventFactoryEvdev() {
129 } 131 }
130 132
131 void EventFactoryEvdev::Init() { 133 void EventFactoryEvdev::Init() {
132 DCHECK(!initialized_); 134 DCHECK(!initialized_);
133 135
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 double radius_y = params.radii.y(); 226 double radius_y = params.radii.y();
225 227
226 // Transform the event to align touches to the image based on display mode. 228 // Transform the event to align touches to the image based on display mode.
227 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x, 229 DeviceDataManager::GetInstance()->ApplyTouchTransformer(params.device_id, &x,
228 &y); 230 &y);
229 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, 231 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id,
230 &radius_x); 232 &radius_x);
231 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id, 233 DeviceDataManager::GetInstance()->ApplyTouchRadiusScale(params.device_id,
232 &radius_y); 234 &radius_y);
233 235
236 // params.slot is guaranteed to be < kNumTouchEvdevSlots.
237 int touch_id = touch_id_generator_.GetGeneratedID(
238 params.device_id * kNumTouchEvdevSlots + params.slot);
234 TouchEvent touch_event(params.type, gfx::PointF(x, y), 239 TouchEvent touch_event(params.type, gfx::PointF(x, y),
235 modifiers_.GetModifierFlags(), params.touch_id, 240 modifiers_.GetModifierFlags(), touch_id,
236 params.timestamp, radius_x, radius_y, 241 params.timestamp, radius_x, radius_y,
237 /* angle */ 0.f, params.pressure); 242 /* angle */ 0.f, params.pressure);
238 touch_event.set_source_device_id(params.device_id); 243 touch_event.set_source_device_id(params.device_id);
239 DispatchUiEvent(&touch_event); 244 DispatchUiEvent(&touch_event);
245
246 if (params.type == ET_TOUCH_RELEASED || params.type == ET_TOUCH_CANCELLED) {
247 touch_id_generator_.ReleaseGeneratedID(touch_event.touch_id());
248 }
240 } 249 }
241 250
242 void EventFactoryEvdev::DispatchUiEvent(Event* event) { 251 void EventFactoryEvdev::DispatchUiEvent(Event* event) {
243 // DispatchEvent takes PlatformEvent which is void*. This function 252 // DispatchEvent takes PlatformEvent which is void*. This function
244 // wraps it with the real type. 253 // wraps it with the real type.
245 DispatchEvent(event); 254 DispatchEvent(event);
246 } 255 }
247 256
248 void EventFactoryEvdev::DispatchKeyboardDevicesUpdated( 257 void EventFactoryEvdev::DispatchKeyboardDevicesUpdated(
249 const std::vector<KeyboardDevice>& devices) { 258 const std::vector<KeyboardDevice>& devices) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 342
334 // Hook up device configuration. 343 // Hook up device configuration.
335 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get()); 344 input_controller_.SetInputDeviceFactory(input_device_factory_proxy_.get());
336 345
337 // Scan & monitor devices. 346 // Scan & monitor devices.
338 device_manager_->AddObserver(this); 347 device_manager_->AddObserver(this);
339 device_manager_->ScanDevices(this); 348 device_manager_->ScanDevices(this);
340 } 349 }
341 350
342 } // namespace ui 351 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_factory_evdev.h ('k') | ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698