Chromium Code Reviews| Index: ui/events/ozone/evdev/touch_event_converter_evdev.cc |
| diff --git a/ui/events/ozone/evdev/touch_event_converter_evdev.cc b/ui/events/ozone/evdev/touch_event_converter_evdev.cc |
| index c46608d938577b8a3ec79c290e71ab7be7ddf89b..71dc635efba77c57ce04c9d4c09d3b74fbefaef9 100644 |
| --- a/ui/events/ozone/evdev/touch_event_converter_evdev.cc |
| +++ b/ui/events/ozone/evdev/touch_event_converter_evdev.cc |
| @@ -188,7 +188,9 @@ void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { |
| info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MINOR, i, 0) / 2.0f; |
| events_[i].pressure = ScalePressure( |
| info.GetAbsMtSlotValueWithDefault(ABS_MT_PRESSURE, i, 0)); |
| - events_[i].cancelled = (major_max_ > 0 && touch_major == major_max_); |
| + if (major_max_ > 0 && touch_major == major_max_) { |
| + CancelAllTouches(); |
|
spang
2017/01/19 01:25:51
Can this move after the loop so it runs at most on
denniskempin
2017/01/20 02:04:39
Done.
|
| + } |
| } |
| } else { |
| // TODO(spang): Add key state to EventDeviceInfo to allow initial contact. |
| @@ -371,8 +373,9 @@ void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { |
| // The MT protocol cannot communicate cancelled touches, so some kernel |
| // drivers will identify palms by setting touch major to max. |
| - if (major_max_ > 0 && input.value == major_max_) |
| - events_[current_slot_].cancelled = true; |
| + if (major_max_ > 0 && input.value == major_max_) { |
| + CancelAllTouches(); |
|
spang
2017/01/19 01:25:51
What if we get a new contact with a lower numbered
denniskempin
2017/01/20 02:04:39
Done.
|
| + } |
| break; |
| case ABS_MT_TOUCH_MINOR: |
| events_[current_slot_].radius_y = input.value / 2.0f; |
| @@ -445,14 +448,31 @@ void TouchEventConverterEvdev::ReportTouchEvent( |
| gfx::PointF(event.x, event.y), details, timestamp)); |
| } |
| +void TouchEventConverterEvdev::CancelAllTouches() { |
| + for (size_t i = 0; i < events_.size(); i++) { |
| + InProgressTouchEvdev* event = &events_[i]; |
| + if (event->was_touching || event->touching) { |
| + event->cancelled = true; |
| + event->altered = true; |
| + } |
| + } |
| +} |
| + |
| void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { |
| if (dropped_events_) { |
| Reinitialize(); |
| dropped_events_ = false; |
| } |
| - if (touch_noise_finder_) |
| + if (touch_noise_finder_) { |
| touch_noise_finder_->HandleTouches(events_, timestamp); |
| + for (size_t i = 0; i < events_.size(); i++) { |
| + if (touch_noise_finder_->SlotHasNoise(events_[i].slot)) { |
| + CancelAllTouches(); |
| + break; |
| + } |
| + } |
| + } |
| for (size_t i = 0; i < events_.size(); i++) { |
| InProgressTouchEvdev* event = &events_[i]; |
| @@ -462,9 +482,6 @@ void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { |
| if (enable_palm_suppression_callback_) |
| enable_palm_suppression_callback_.Run(event->tool_code > 0); |
| - if (touch_noise_finder_ && touch_noise_finder_->SlotHasNoise(event->slot)) |
| - event->cancelled = true; |
| - |
| EventType event_type = GetEventTypeForTouch(*event); |
| // The tool type is fixed with the touch pressed event and does not change. |
| if (event_type == ET_TOUCH_PRESSED) |