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

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

Issue 2640163003: ozone: Cancel all touches once a single touch is cancelled (Closed)
Patch Set: ozone: Cancel all touches once a single touch is cancelled Created 3 years, 11 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
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/touch_event_converter_evdev.h" 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/input.h> 9 #include <linux/input.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 events_[i].altered = true; 181 events_[i].altered = true;
182 182
183 // Optional bits. 183 // Optional bits.
184 int touch_major = 184 int touch_major =
185 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MAJOR, i, 0); 185 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MAJOR, i, 0);
186 events_[i].radius_x = touch_major / 2.0f; 186 events_[i].radius_x = touch_major / 2.0f;
187 events_[i].radius_y = 187 events_[i].radius_y =
188 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MINOR, i, 0) / 2.0f; 188 info.GetAbsMtSlotValueWithDefault(ABS_MT_TOUCH_MINOR, i, 0) / 2.0f;
189 events_[i].pressure = ScalePressure( 189 events_[i].pressure = ScalePressure(
190 info.GetAbsMtSlotValueWithDefault(ABS_MT_PRESSURE, i, 0)); 190 info.GetAbsMtSlotValueWithDefault(ABS_MT_PRESSURE, i, 0));
191 events_[i].cancelled = (major_max_ > 0 && touch_major == major_max_); 191 if (major_max_ > 0 && touch_major == major_max_) {
192 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.
193 }
192 } 194 }
193 } else { 195 } else {
194 // TODO(spang): Add key state to EventDeviceInfo to allow initial contact. 196 // TODO(spang): Add key state to EventDeviceInfo to allow initial contact.
195 // (and make sure to take into account quirk_left_mouse_button_) 197 // (and make sure to take into account quirk_left_mouse_button_)
196 events_[0].x = 0; 198 events_[0].x = 0;
197 events_[0].y = 0; 199 events_[0].y = 0;
198 events_[0].tracking_id = kTrackingIdForUnusedSlot; 200 events_[0].tracking_id = kTrackingIdForUnusedSlot;
199 events_[0].touching = false; 201 events_[0].touching = false;
200 events_[0].slot = 0; 202 events_[0].slot = 0;
201 events_[0].radius_x = 0; 203 events_[0].radius_x = 0;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { 366 void TouchEventConverterEvdev::ProcessAbs(const input_event& input) {
365 switch (input.code) { 367 switch (input.code) {
366 case ABS_MT_TOUCH_MAJOR: 368 case ABS_MT_TOUCH_MAJOR:
367 // TODO(spang): If we have all of major, minor, and orientation, 369 // TODO(spang): If we have all of major, minor, and orientation,
368 // we can scale the ellipse correctly. However on the Pixel we get 370 // we can scale the ellipse correctly. However on the Pixel we get
369 // neither minor nor orientation, so this is all we can do. 371 // neither minor nor orientation, so this is all we can do.
370 events_[current_slot_].radius_x = input.value / 2.0f; 372 events_[current_slot_].radius_x = input.value / 2.0f;
371 373
372 // The MT protocol cannot communicate cancelled touches, so some kernel 374 // The MT protocol cannot communicate cancelled touches, so some kernel
373 // drivers will identify palms by setting touch major to max. 375 // drivers will identify palms by setting touch major to max.
374 if (major_max_ > 0 && input.value == major_max_) 376 if (major_max_ > 0 && input.value == major_max_) {
375 events_[current_slot_].cancelled = true; 377 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.
378 }
376 break; 379 break;
377 case ABS_MT_TOUCH_MINOR: 380 case ABS_MT_TOUCH_MINOR:
378 events_[current_slot_].radius_y = input.value / 2.0f; 381 events_[current_slot_].radius_y = input.value / 2.0f;
379 break; 382 break;
380 case ABS_MT_POSITION_X: 383 case ABS_MT_POSITION_X:
381 events_[current_slot_].x = input.value; 384 events_[current_slot_].x = input.value;
382 break; 385 break;
383 case ABS_MT_POSITION_Y: 386 case ABS_MT_POSITION_Y:
384 events_[current_slot_].y = input.value; 387 events_[current_slot_].y = input.value;
385 break; 388 break;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 EventType event_type, 441 EventType event_type,
439 base::TimeTicks timestamp) { 442 base::TimeTicks timestamp) {
440 ui::PointerDetails details(event.reported_tool_type, event.radius_x, 443 ui::PointerDetails details(event.reported_tool_type, event.radius_x,
441 event.radius_y, event.pressure, 444 event.radius_y, event.pressure,
442 /* tilt_x */ 0.0f, /* tilt_y */ 0.0f); 445 /* tilt_x */ 0.0f, /* tilt_y */ 0.0f);
443 dispatcher_->DispatchTouchEvent( 446 dispatcher_->DispatchTouchEvent(
444 TouchEventParams(input_device_.id, event.slot, event_type, 447 TouchEventParams(input_device_.id, event.slot, event_type,
445 gfx::PointF(event.x, event.y), details, timestamp)); 448 gfx::PointF(event.x, event.y), details, timestamp));
446 } 449 }
447 450
451 void TouchEventConverterEvdev::CancelAllTouches() {
452 for (size_t i = 0; i < events_.size(); i++) {
453 InProgressTouchEvdev* event = &events_[i];
454 if (event->was_touching || event->touching) {
455 event->cancelled = true;
456 event->altered = true;
457 }
458 }
459 }
460
448 void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { 461 void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) {
449 if (dropped_events_) { 462 if (dropped_events_) {
450 Reinitialize(); 463 Reinitialize();
451 dropped_events_ = false; 464 dropped_events_ = false;
452 } 465 }
453 466
454 if (touch_noise_finder_) 467 if (touch_noise_finder_) {
455 touch_noise_finder_->HandleTouches(events_, timestamp); 468 touch_noise_finder_->HandleTouches(events_, timestamp);
469 for (size_t i = 0; i < events_.size(); i++) {
470 if (touch_noise_finder_->SlotHasNoise(events_[i].slot)) {
471 CancelAllTouches();
472 break;
473 }
474 }
475 }
456 476
457 for (size_t i = 0; i < events_.size(); i++) { 477 for (size_t i = 0; i < events_.size(); i++) {
458 InProgressTouchEvdev* event = &events_[i]; 478 InProgressTouchEvdev* event = &events_[i];
459 if (!event->altered) 479 if (!event->altered)
460 continue; 480 continue;
461 481
462 if (enable_palm_suppression_callback_) 482 if (enable_palm_suppression_callback_)
463 enable_palm_suppression_callback_.Run(event->tool_code > 0); 483 enable_palm_suppression_callback_.Run(event->tool_code > 0);
464 484
465 if (touch_noise_finder_ && touch_noise_finder_->SlotHasNoise(event->slot))
466 event->cancelled = true;
467
468 EventType event_type = GetEventTypeForTouch(*event); 485 EventType event_type = GetEventTypeForTouch(*event);
469 // The tool type is fixed with the touch pressed event and does not change. 486 // The tool type is fixed with the touch pressed event and does not change.
470 if (event_type == ET_TOUCH_PRESSED) 487 if (event_type == ET_TOUCH_PRESSED)
471 event->reported_tool_type = GetEventPointerType(event->tool_code); 488 event->reported_tool_type = GetEventPointerType(event->tool_code);
472 if (event_type != ET_UNKNOWN) 489 if (event_type != ET_UNKNOWN)
473 ReportTouchEvent(*event, event_type, timestamp); 490 ReportTouchEvent(*event, event_type, timestamp);
474 491
475 event->was_cancelled = event->cancelled; 492 event->was_cancelled = event->cancelled;
476 event->was_touching = event->touching; 493 event->was_touching = event->touching;
477 event->altered = false; 494 event->altered = false;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (pressure_max_ - pressure_min_) 549 if (pressure_max_ - pressure_min_)
533 pressure /= pressure_max_ - pressure_min_; 550 pressure /= pressure_max_ - pressure_min_;
534 return pressure; 551 return pressure;
535 } 552 }
536 553
537 int TouchEventConverterEvdev::NextTrackingId() { 554 int TouchEventConverterEvdev::NextTrackingId() {
538 return next_tracking_id_++ & kMaxTrackingId; 555 return next_tracking_id_++ & kMaxTrackingId;
539 } 556 }
540 557
541 } // namespace ui 558 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698