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

Side by Side Diff: ui/chromeos/touch_exploration_controller.cc

Issue 2655303004: Add id properties to PointerEvent (Closed)
Patch Set: pointer id Created 3 years, 10 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/chromeos/touch_exploration_controller.h" 5 #include "ui/chromeos/touch_exploration_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 if (passthrough_timer_.IsRunning() && 124 if (passthrough_timer_.IsRunning() &&
125 event.time_stamp() - initial_press_->time_stamp() > 125 event.time_stamp() - initial_press_->time_stamp() >
126 gesture_detector_config_.longpress_timeout) { 126 gesture_detector_config_.longpress_timeout) {
127 passthrough_timer_.Stop(); 127 passthrough_timer_.Stop();
128 OnPassthroughTimerFired(); 128 OnPassthroughTimerFired();
129 } 129 }
130 130
131 const ui::EventType type = touch_event.type(); 131 const ui::EventType type = touch_event.type();
132 const gfx::PointF& location = touch_event.location_f(); 132 const gfx::PointF& location = touch_event.location_f();
133 const int touch_id = touch_event.touch_id(); 133 const int touch_id = touch_event.pointer_details().id;
134 134
135 // Always update touch ids and touch locations, so we can use those 135 // Always update touch ids and touch locations, so we can use those
136 // no matter what state we're in. 136 // no matter what state we're in.
137 if (type == ui::ET_TOUCH_PRESSED) { 137 if (type == ui::ET_TOUCH_PRESSED) {
138 current_touch_ids_.push_back(touch_id); 138 current_touch_ids_.push_back(touch_id);
139 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location)); 139 touch_locations_.insert(std::pair<int, gfx::PointF>(touch_id, location));
140 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 140 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
141 std::vector<int>::iterator it = std::find( 141 std::vector<int>::iterator it = std::find(
142 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id); 142 current_touch_ids_.begin(), current_touch_ids_.end(), touch_id);
143 143
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 bool in_a_bottom_corner = 276 bool in_a_bottom_corner =
277 (BOTTOM_LEFT_CORNER == location) || (BOTTOM_RIGHT_CORNER == location); 277 (BOTTOM_LEFT_CORNER == location) || (BOTTOM_RIGHT_CORNER == location);
278 if (in_a_bottom_corner) { 278 if (in_a_bottom_corner) {
279 passthrough_timer_.Start( 279 passthrough_timer_.Start(
280 FROM_HERE, 280 FROM_HERE,
281 gesture_detector_config_.longpress_timeout, 281 gesture_detector_config_.longpress_timeout,
282 this, 282 this,
283 &TouchExplorationController::OnPassthroughTimerFired); 283 &TouchExplorationController::OnPassthroughTimerFired);
284 } 284 }
285 initial_press_.reset(new TouchEvent(event)); 285 initial_press_.reset(new TouchEvent(event));
286 initial_presses_[event.touch_id()] = event.location(); 286 initial_presses_[event.pointer_details().id] = event.location();
287 last_unused_finger_event_.reset(new TouchEvent(event)); 287 last_unused_finger_event_.reset(new TouchEvent(event));
288 StartTapTimer(); 288 StartTapTimer();
289 SET_STATE(SINGLE_TAP_PRESSED); 289 SET_STATE(SINGLE_TAP_PRESSED);
290 return ui::EVENT_REWRITE_DISCARD; 290 return ui::EVENT_REWRITE_DISCARD;
291 } 291 }
292 292
293 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( 293 ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
294 const ui::TouchEvent& event, 294 const ui::TouchEvent& event,
295 std::unique_ptr<ui::Event>* rewritten_event) { 295 std::unique_ptr<ui::Event>* rewritten_event) {
296 const ui::EventType type = event.type(); 296 const ui::EventType type = event.type();
297 297
298 int location = FindEdgesWithinBounds(event.location(), kMaxDistanceFromEdge); 298 int location = FindEdgesWithinBounds(event.location(), kMaxDistanceFromEdge);
299 bool in_a_bottom_corner = 299 bool in_a_bottom_corner =
300 (location == BOTTOM_LEFT_CORNER) || (location == BOTTOM_RIGHT_CORNER); 300 (location == BOTTOM_LEFT_CORNER) || (location == BOTTOM_RIGHT_CORNER);
301 // If the event is from the initial press and the location is no longer in the 301 // If the event is from the initial press and the location is no longer in the
302 // corner, then we are not waiting for a corner passthrough anymore. 302 // corner, then we are not waiting for a corner passthrough anymore.
303 if (event.touch_id() == initial_press_->touch_id() && !in_a_bottom_corner) { 303 if (event.pointer_details().id == initial_press_->pointer_details().id &&
304 !in_a_bottom_corner) {
304 if (passthrough_timer_.IsRunning()) { 305 if (passthrough_timer_.IsRunning()) {
305 passthrough_timer_.Stop(); 306 passthrough_timer_.Stop();
306 // Since the long press timer has been running, it is possible that the 307 // Since the long press timer has been running, it is possible that the
307 // tap timer has timed out before the long press timer has. If the tap 308 // tap timer has timed out before the long press timer has. If the tap
308 // timer timeout has elapsed, then fire the tap timer. 309 // timer timeout has elapsed, then fire the tap timer.
309 if (event.time_stamp() - initial_press_->time_stamp() > 310 if (event.time_stamp() - initial_press_->time_stamp() >
310 gesture_detector_config_.double_tap_timeout) { 311 gesture_detector_config_.double_tap_timeout) {
311 OnTapTimerFired(); 312 OnTapTimerFired();
312 } 313 }
313 } 314 }
314 } 315 }
315 316
316 if (type == ui::ET_TOUCH_PRESSED) { 317 if (type == ui::ET_TOUCH_PRESSED) {
317 initial_presses_[event.touch_id()] = event.location(); 318 initial_presses_[event.pointer_details().id] = event.location();
318 SET_STATE(TWO_FINGER_TAP); 319 SET_STATE(TWO_FINGER_TAP);
319 return EVENT_REWRITE_DISCARD; 320 return EVENT_REWRITE_DISCARD;
320 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 321 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
321 if (passthrough_timer_.IsRunning()) 322 if (passthrough_timer_.IsRunning())
322 passthrough_timer_.Stop(); 323 passthrough_timer_.Stop();
323 if (current_touch_ids_.size() == 0 && 324 if (current_touch_ids_.size() == 0 &&
324 event.touch_id() == initial_press_->touch_id()) { 325 event.pointer_details().id == initial_press_->pointer_details().id) {
325 SET_STATE(SINGLE_TAP_RELEASED); 326 SET_STATE(SINGLE_TAP_RELEASED);
326 } else if (current_touch_ids_.size() == 0) { 327 } else if (current_touch_ids_.size() == 0) {
327 SET_STATE(NO_FINGERS_DOWN); 328 SET_STATE(NO_FINGERS_DOWN);
328 } 329 }
329 return EVENT_REWRITE_DISCARD; 330 return EVENT_REWRITE_DISCARD;
330 } else if (type == ui::ET_TOUCH_MOVED) { 331 } else if (type == ui::ET_TOUCH_MOVED) {
331 float distance = (event.location() - initial_press_->location()).Length(); 332 float distance = (event.location() - initial_press_->location()).Length();
332 // If the user does not move far enough from the original position, then the 333 // If the user does not move far enough from the original position, then the
333 // resulting movement should not be considered to be a deliberate gesture or 334 // resulting movement should not be considered to be a deliberate gesture or
334 // touch exploration. 335 // touch exploration.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 500 }
500 return ui::EVENT_REWRITE_DISCARD; 501 return ui::EVENT_REWRITE_DISCARD;
501 } 502 }
502 503
503 ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough( 504 ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough(
504 const ui::TouchEvent& event, 505 const ui::TouchEvent& event,
505 std::unique_ptr<ui::Event>* rewritten_event) { 506 std::unique_ptr<ui::Event>* rewritten_event) {
506 ui::EventType type = event.type(); 507 ui::EventType type = event.type();
507 508
508 // If the first finger has left the corner, then exit passthrough. 509 // If the first finger has left the corner, then exit passthrough.
509 if (event.touch_id() == initial_press_->touch_id()) { 510 if (event.pointer_details().id == initial_press_->pointer_details().id) {
510 int edges = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge); 511 int edges = FindEdgesWithinBounds(event.location(), kSlopDistanceFromEdge);
511 bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) || 512 bool in_a_bottom_corner = (edges == BOTTOM_LEFT_CORNER) ||
512 (edges == BOTTOM_RIGHT_CORNER); 513 (edges == BOTTOM_RIGHT_CORNER);
513 if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner) 514 if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner)
514 return ui::EVENT_REWRITE_DISCARD; 515 return ui::EVENT_REWRITE_DISCARD;
515 516
516 if (current_touch_ids_.size() == 0) { 517 if (current_touch_ids_.size() == 0) {
517 SET_STATE(NO_FINGERS_DOWN); 518 SET_STATE(NO_FINGERS_DOWN);
518 return ui::EVENT_REWRITE_DISCARD; 519 return ui::EVENT_REWRITE_DISCARD;
519 } 520 }
520 SET_STATE(WAIT_FOR_NO_FINGERS); 521 SET_STATE(WAIT_FOR_NO_FINGERS);
521 return ui::EVENT_REWRITE_DISCARD; 522 return ui::EVENT_REWRITE_DISCARD;
522 } 523 }
523 524
524 std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( 525 std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent(
525 type, gfx::Point(), event.touch_id(), event.time_stamp())); 526 type, gfx::Point(), event.pointer_details().id, event.time_stamp()));
526 new_event->set_location_f(event.location_f()); 527 new_event->set_location_f(event.location_f());
527 new_event->set_root_location_f(event.location_f()); 528 new_event->set_root_location_f(event.location_f());
528 new_event->set_flags(event.flags()); 529 new_event->set_flags(event.flags());
529 *rewritten_event = std::move(new_event); 530 *rewritten_event = std::move(new_event);
530 531
531 if (current_touch_ids_.size() == 0) 532 if (current_touch_ids_.size() == 0)
532 SET_STATE(NO_FINGERS_DOWN); 533 SET_STATE(NO_FINGERS_DOWN);
533 534
534 return ui::EVENT_REWRITE_REWRITTEN; 535 return ui::EVENT_REWRITE_REWRITTEN;
535 } 536 }
536 537
537 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough( 538 ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough(
538 const ui::TouchEvent& event, 539 const ui::TouchEvent& event,
539 std::unique_ptr<ui::Event>* rewritten_event) { 540 std::unique_ptr<ui::Event>* rewritten_event) {
540 if (event.touch_id() != initial_press_->touch_id()) { 541 if (event.pointer_details().id != initial_press_->pointer_details().id) {
541 if (current_touch_ids_.size() == 0) { 542 if (current_touch_ids_.size() == 0) {
542 SET_STATE(NO_FINGERS_DOWN); 543 SET_STATE(NO_FINGERS_DOWN);
543 } 544 }
544 return ui::EVENT_REWRITE_DISCARD; 545 return ui::EVENT_REWRITE_DISCARD;
545 } 546 }
546 std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent( 547 std::unique_ptr<ui::TouchEvent> new_event(
547 event.type(), gfx::Point(), event.touch_id(), event.time_stamp())); 548 new ui::TouchEvent(event.type(), gfx::Point(), event.pointer_details().id,
549 event.time_stamp()));
548 new_event->set_location_f(event.location_f() - passthrough_offset_); 550 new_event->set_location_f(event.location_f() - passthrough_offset_);
549 new_event->set_root_location_f(event.location_f() - passthrough_offset_); 551 new_event->set_root_location_f(event.location_f() - passthrough_offset_);
550 new_event->set_flags(event.flags()); 552 new_event->set_flags(event.flags());
551 *rewritten_event = std::move(new_event); 553 *rewritten_event = std::move(new_event);
552 if (current_touch_ids_.size() == 0) { 554 if (current_touch_ids_.size() == 0) {
553 SET_STATE(NO_FINGERS_DOWN); 555 SET_STATE(NO_FINGERS_DOWN);
554 } 556 }
555 return ui::EVENT_REWRITE_REWRITTEN; 557 return ui::EVENT_REWRITE_REWRITTEN;
556 } 558 }
557 559
558 ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress( 560 ui::EventRewriteStatus TouchExplorationController::InTouchExploreSecondPress(
559 const ui::TouchEvent& event, 561 const ui::TouchEvent& event,
560 std::unique_ptr<ui::Event>* rewritten_event) { 562 std::unique_ptr<ui::Event>* rewritten_event) {
561 ui::EventType type = event.type(); 563 ui::EventType type = event.type();
562 if (type == ui::ET_TOUCH_PRESSED) { 564 if (type == ui::ET_TOUCH_PRESSED) {
563 // A third finger being pressed means that a split tap can no longer go 565 // A third finger being pressed means that a split tap can no longer go
564 // through. The user enters the wait state, Since there has already been 566 // through. The user enters the wait state, Since there has already been
565 // a press dispatched when split tap began, the touch needs to be 567 // a press dispatched when split tap began, the touch needs to be
566 // cancelled. 568 // cancelled.
567 std::unique_ptr<ui::TouchEvent> new_event( 569 std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent(
568 new ui::TouchEvent(ui::ET_TOUCH_CANCELLED, gfx::Point(), 570 ui::ET_TOUCH_CANCELLED, gfx::Point(),
569 initial_press_->touch_id(), event.time_stamp())); 571 initial_press_->pointer_details().id, event.time_stamp()));
570 // TODO(dmazzoni): fix for multiple displays. http://crbug.com/616793 572 // TODO(dmazzoni): fix for multiple displays. http://crbug.com/616793
571 new_event->set_location_f(anchor_point_); 573 new_event->set_location_f(anchor_point_);
572 new_event->set_root_location_f(anchor_point_); 574 new_event->set_root_location_f(anchor_point_);
573 new_event->set_flags(event.flags()); 575 new_event->set_flags(event.flags());
574 *rewritten_event = std::move(new_event); 576 *rewritten_event = std::move(new_event);
575 SET_STATE(WAIT_FOR_NO_FINGERS); 577 SET_STATE(WAIT_FOR_NO_FINGERS);
576 return ui::EVENT_REWRITE_REWRITTEN; 578 return ui::EVENT_REWRITE_REWRITTEN;
577 } else if (type == ui::ET_TOUCH_MOVED) { 579 } else if (type == ui::ET_TOUCH_MOVED) {
578 // If the fingers have moved too far from their original locations, 580 // If the fingers have moved too far from their original locations,
579 // the user can no longer split tap. 581 // the user can no longer split tap.
580 ui::TouchEvent* original_touch; 582 ui::TouchEvent* original_touch;
581 if (event.touch_id() == last_touch_exploration_->touch_id()) { 583 if (event.pointer_details().id ==
584 last_touch_exploration_->pointer_details().id) {
582 original_touch = last_touch_exploration_.get(); 585 original_touch = last_touch_exploration_.get();
583 } else if (event.touch_id() == initial_press_->touch_id()) { 586 } else if (event.pointer_details().id ==
587 initial_press_->pointer_details().id) {
584 original_touch = initial_press_.get(); 588 original_touch = initial_press_.get();
585 } else { 589 } else {
586 NOTREACHED(); 590 NOTREACHED();
587 SET_STATE(WAIT_FOR_NO_FINGERS); 591 SET_STATE(WAIT_FOR_NO_FINGERS);
588 return ui::EVENT_REWRITE_DISCARD; 592 return ui::EVENT_REWRITE_DISCARD;
589 } 593 }
590 // Check the distance between the current finger location and the original 594 // Check the distance between the current finger location and the original
591 // location. The slop for this is a bit more generous since keeping two 595 // location. The slop for this is a bit more generous since keeping two
592 // fingers in place is a bit harder. If the user has left the slop, the 596 // fingers in place is a bit harder. If the user has left the slop, the
593 // user enters the wait state. 597 // user enters the wait state.
594 if ((event.location_f() - original_touch->location_f()).Length() > 598 if ((event.location_f() - original_touch->location_f()).Length() >
595 GetSplitTapTouchSlop()) { 599 GetSplitTapTouchSlop()) {
596 SET_STATE(WAIT_FOR_NO_FINGERS); 600 SET_STATE(WAIT_FOR_NO_FINGERS);
597 } 601 }
598 return ui::EVENT_REWRITE_DISCARD; 602 return ui::EVENT_REWRITE_DISCARD;
599 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { 603 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
600 // If the touch exploration finger is lifted, there is no option to return 604 // If the touch exploration finger is lifted, there is no option to return
601 // to touch explore anymore. The remaining finger acts as a pending 605 // to touch explore anymore. The remaining finger acts as a pending
602 // tap or long tap for the last touch explore location. 606 // tap or long tap for the last touch explore location.
603 if (event.touch_id() == last_touch_exploration_->touch_id()) { 607 if (event.pointer_details().id ==
608 last_touch_exploration_->pointer_details().id) {
604 SET_STATE(TOUCH_RELEASE_PENDING); 609 SET_STATE(TOUCH_RELEASE_PENDING);
605 return EVENT_REWRITE_DISCARD; 610 return EVENT_REWRITE_DISCARD;
606 } 611 }
607 612
608 // Continue to release the touch only if the touch explore finger is the 613 // Continue to release the touch only if the touch explore finger is the
609 // only finger remaining. 614 // only finger remaining.
610 if (current_touch_ids_.size() != 1) 615 if (current_touch_ids_.size() != 1)
611 return EVENT_REWRITE_DISCARD; 616 return EVENT_REWRITE_DISCARD;
612 617
613 SendSimulatedClick(); 618 SendSimulatedClick();
(...skipping 26 matching lines...) Expand all
640 return; 645 return;
641 } 646 }
642 647
643 // If we don't have an anchor point, we can't send a simulated click. 648 // If we don't have an anchor point, we can't send a simulated click.
644 if (anchor_point_state_ == ANCHOR_POINT_NONE) 649 if (anchor_point_state_ == ANCHOR_POINT_NONE)
645 return; 650 return;
646 651
647 // Otherwise send a simulated press/release at the anchor point. 652 // Otherwise send a simulated press/release at the anchor point.
648 std::unique_ptr<ui::TouchEvent> touch_press; 653 std::unique_ptr<ui::TouchEvent> touch_press;
649 touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), 654 touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(),
650 initial_press_->touch_id(), Now())); 655 initial_press_->pointer_details().id,
656 Now()));
651 touch_press->set_location_f(anchor_point_); 657 touch_press->set_location_f(anchor_point_);
652 touch_press->set_root_location_f(anchor_point_); 658 touch_press->set_root_location_f(anchor_point_);
653 DispatchEvent(touch_press.get()); 659 DispatchEvent(touch_press.get());
654 660
655 std::unique_ptr<ui::TouchEvent> touch_release; 661 std::unique_ptr<ui::TouchEvent> touch_release;
656 touch_release.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), 662 touch_release.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(),
657 initial_press_->touch_id(), Now())); 663 initial_press_->pointer_details().id,
664 Now()));
658 touch_release->set_location_f(anchor_point_); 665 touch_release->set_location_f(anchor_point_);
659 touch_release->set_root_location_f(anchor_point_); 666 touch_release->set_root_location_f(anchor_point_);
660 DispatchEvent(touch_release.get()); 667 DispatchEvent(touch_release.get());
661 } 668 }
662 669
663 ui::EventRewriteStatus TouchExplorationController::InSlideGesture( 670 ui::EventRewriteStatus TouchExplorationController::InSlideGesture(
664 const ui::TouchEvent& event, 671 const ui::TouchEvent& event,
665 std::unique_ptr<ui::Event>* rewritten_event) { 672 std::unique_ptr<ui::Event>* rewritten_event) {
666 // The timer should not fire when sliding. 673 // The timer should not fire when sliding.
667 tap_timer_.Stop(); 674 tap_timer_.Stop();
668 675
669 ui::EventType type = event.type(); 676 ui::EventType type = event.type();
670 // If additional fingers are added before a swipe gesture has been registered, 677 // If additional fingers are added before a swipe gesture has been registered,
671 // then wait until all fingers have been lifted. 678 // then wait until all fingers have been lifted.
672 if (type == ui::ET_TOUCH_PRESSED || 679 if (type == ui::ET_TOUCH_PRESSED ||
673 event.touch_id() != initial_press_->touch_id()) { 680 event.pointer_details().id != initial_press_->pointer_details().id) {
674 if (sound_timer_.IsRunning()) 681 if (sound_timer_.IsRunning())
675 sound_timer_.Stop(); 682 sound_timer_.Stop();
676 SET_STATE(WAIT_FOR_NO_FINGERS); 683 SET_STATE(WAIT_FOR_NO_FINGERS);
677 return EVENT_REWRITE_DISCARD; 684 return EVENT_REWRITE_DISCARD;
678 } 685 }
679 686
680 // There should not be more than one finger down. 687 // There should not be more than one finger down.
681 DCHECK_LE(current_touch_ids_.size(), 1U); 688 DCHECK_LE(current_touch_ids_.size(), 1U);
682 689
683 // Allows user to return to the edge to adjust the sound if they have left the 690 // Allows user to return to the edge to adjust the sound if they have left the
(...skipping 26 matching lines...) Expand all
710 std::unique_ptr<ui::Event>* rewritten_event) { 717 std::unique_ptr<ui::Event>* rewritten_event) {
711 ui::EventType type = event.type(); 718 ui::EventType type = event.type();
712 if (type == ui::ET_TOUCH_PRESSED) { 719 if (type == ui::ET_TOUCH_PRESSED) {
713 // This is now a three finger gesture. 720 // This is now a three finger gesture.
714 SET_STATE(GESTURE_IN_PROGRESS); 721 SET_STATE(GESTURE_IN_PROGRESS);
715 return ui::EVENT_REWRITE_DISCARD; 722 return ui::EVENT_REWRITE_DISCARD;
716 } 723 }
717 724
718 if (type == ui::ET_TOUCH_MOVED) { 725 if (type == ui::ET_TOUCH_MOVED) {
719 // Determine if it was a swipe. 726 // Determine if it was a swipe.
720 gfx::Point original_location = initial_presses_[event.touch_id()]; 727 gfx::Point original_location = initial_presses_[event.pointer_details().id];
721 float distance = (event.location() - original_location).Length(); 728 float distance = (event.location() - original_location).Length();
722 // If the user moves too far from the original position, consider the 729 // If the user moves too far from the original position, consider the
723 // movement a swipe. 730 // movement a swipe.
724 if (distance > gesture_detector_config_.touch_slop) { 731 if (distance > gesture_detector_config_.touch_slop) {
725 SET_STATE(GESTURE_IN_PROGRESS); 732 SET_STATE(GESTURE_IN_PROGRESS);
726 } 733 }
727 return ui::EVENT_REWRITE_DISCARD; 734 return ui::EVENT_REWRITE_DISCARD;
728 } 735 }
729 736
730 if (current_touch_ids_.size() != 0) 737 if (current_touch_ids_.size() != 0)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 case TOUCH_EXPLORE_RELEASED: 770 case TOUCH_EXPLORE_RELEASED:
764 SET_STATE(NO_FINGERS_DOWN); 771 SET_STATE(NO_FINGERS_DOWN);
765 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); 772 last_touch_exploration_.reset(new TouchEvent(*initial_press_));
766 anchor_point_ = last_touch_exploration_->location_f(); 773 anchor_point_ = last_touch_exploration_->location_f();
767 anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION; 774 anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION;
768 return; 775 return;
769 case DOUBLE_TAP_PENDING: { 776 case DOUBLE_TAP_PENDING: {
770 SET_STATE(ONE_FINGER_PASSTHROUGH); 777 SET_STATE(ONE_FINGER_PASSTHROUGH);
771 passthrough_offset_ = 778 passthrough_offset_ =
772 last_unused_finger_event_->location_f() - anchor_point_; 779 last_unused_finger_event_->location_f() - anchor_point_;
773 std::unique_ptr<ui::TouchEvent> passthrough_press( 780 std::unique_ptr<ui::TouchEvent> passthrough_press(new ui::TouchEvent(
774 new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), 781 ui::ET_TOUCH_PRESSED, gfx::Point(),
775 last_unused_finger_event_->touch_id(), Now())); 782 last_unused_finger_event_->pointer_details().id, Now()));
776 passthrough_press->set_location_f(anchor_point_); 783 passthrough_press->set_location_f(anchor_point_);
777 passthrough_press->set_root_location_f(anchor_point_); 784 passthrough_press->set_root_location_f(anchor_point_);
778 DispatchEvent(passthrough_press.get()); 785 DispatchEvent(passthrough_press.get());
779 return; 786 return;
780 } 787 }
781 case SINGLE_TAP_PRESSED: 788 case SINGLE_TAP_PRESSED:
782 if (passthrough_timer_.IsRunning()) 789 if (passthrough_timer_.IsRunning())
783 return; 790 return;
784 case GESTURE_IN_PROGRESS: 791 case GESTURE_IN_PROGRESS:
785 // If only one finger is down, go into touch exploration. 792 // If only one finger is down, go into touch exploration.
(...skipping 21 matching lines...) Expand all
807 anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION; 814 anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION;
808 } 815 }
809 816
810 void TouchExplorationController::OnPassthroughTimerFired() { 817 void TouchExplorationController::OnPassthroughTimerFired() {
811 // The passthrough timer will only fire if if the user has held a finger in 818 // The passthrough timer will only fire if if the user has held a finger in
812 // one of the passthrough corners for the duration of the passthrough timeout. 819 // one of the passthrough corners for the duration of the passthrough timeout.
813 820
814 // Check that initial press isn't null. Also a check that if the initial 821 // Check that initial press isn't null. Also a check that if the initial
815 // corner press was released, then it should not be in corner passthrough. 822 // corner press was released, then it should not be in corner passthrough.
816 if (!initial_press_ || 823 if (!initial_press_ ||
817 touch_locations_.find(initial_press_->touch_id()) != 824 touch_locations_.find(initial_press_->pointer_details().id) !=
818 touch_locations_.end()) { 825 touch_locations_.end()) {
819 } 826 }
820 827
821 gfx::Point location = 828 gfx::Point location =
822 ToRoundedPoint(touch_locations_[initial_press_->touch_id()]); 829 ToRoundedPoint(touch_locations_[initial_press_->pointer_details().id]);
823 int corner = FindEdgesWithinBounds(location, kSlopDistanceFromEdge); 830 int corner = FindEdgesWithinBounds(location, kSlopDistanceFromEdge);
824 if (corner != BOTTOM_LEFT_CORNER && corner != BOTTOM_RIGHT_CORNER) 831 if (corner != BOTTOM_LEFT_CORNER && corner != BOTTOM_RIGHT_CORNER)
825 return; 832 return;
826 833
827 if (sound_timer_.IsRunning()) 834 if (sound_timer_.IsRunning())
828 sound_timer_.Stop(); 835 sound_timer_.Stop();
829 delegate_->PlayPassthroughEarcon(); 836 delegate_->PlayPassthroughEarcon();
830 SET_STATE(CORNER_PASSTHROUGH); 837 SET_STATE(CORNER_PASSTHROUGH);
831 return; 838 return;
832 } 839 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 VLOG(1) << "\n Function name: " << function_name 1133 VLOG(1) << "\n Function name: " << function_name
1127 << "\n State: " << state_string; 1134 << "\n State: " << state_string;
1128 } 1135 }
1129 1136
1130 void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event, 1137 void TouchExplorationController::VlogEvent(const ui::TouchEvent& touch_event,
1131 const char* function_name) { 1138 const char* function_name) {
1132 if (!VLOG_on_) 1139 if (!VLOG_on_)
1133 return; 1140 return;
1134 1141
1135 if (prev_event_ && prev_event_->type() == touch_event.type() && 1142 if (prev_event_ && prev_event_->type() == touch_event.type() &&
1136 prev_event_->touch_id() == touch_event.touch_id()) { 1143 prev_event_->pointer_details().id == touch_event.pointer_details().id) {
1137 return; 1144 return;
1138 } 1145 }
1139 // The above statement prevents events of the same type and id from being 1146 // The above statement prevents events of the same type and id from being
1140 // printed in a row. However, if two fingers are down, they would both be 1147 // printed in a row. However, if two fingers are down, they would both be
1141 // moving and alternating printing move events unless we check for this. 1148 // moving and alternating printing move events unless we check for this.
1142 if (prev_event_ && prev_event_->type() == ET_TOUCH_MOVED && 1149 if (prev_event_ && prev_event_->type() == ET_TOUCH_MOVED &&
1143 touch_event.type() == ET_TOUCH_MOVED) { 1150 touch_event.type() == ET_TOUCH_MOVED) {
1144 return; 1151 return;
1145 } 1152 }
1146 1153
1147 const std::string& type = touch_event.name(); 1154 const std::string& type = touch_event.name();
1148 const gfx::PointF& location = touch_event.location_f(); 1155 const gfx::PointF& location = touch_event.location_f();
1149 const int touch_id = touch_event.touch_id(); 1156 const int touch_id = touch_event.pointer_details().id;
1150 1157
1151 VLOG(1) << "\n Function name: " << function_name << "\n Event Type: " << type 1158 VLOG(1) << "\n Function name: " << function_name << "\n Event Type: " << type
1152 << "\n Location: " << location.ToString() 1159 << "\n Location: " << location.ToString()
1153 << "\n Touch ID: " << touch_id; 1160 << "\n Touch ID: " << touch_id;
1154 prev_event_.reset(new TouchEvent(touch_event)); 1161 prev_event_.reset(new TouchEvent(touch_event));
1155 } 1162 }
1156 1163
1157 const char* TouchExplorationController::EnumStateToString(State state) { 1164 const char* TouchExplorationController::EnumStateToString(State state) {
1158 switch (state) { 1165 switch (state) {
1159 case NO_FINGERS_DOWN: 1166 case NO_FINGERS_DOWN:
(...skipping 26 matching lines...) Expand all
1186 return "TWO_FINGER_TAP"; 1193 return "TWO_FINGER_TAP";
1187 } 1194 }
1188 return "Not a state"; 1195 return "Not a state";
1189 } 1196 }
1190 1197
1191 float TouchExplorationController::GetSplitTapTouchSlop() { 1198 float TouchExplorationController::GetSplitTapTouchSlop() {
1192 return gesture_detector_config_.touch_slop * 3; 1199 return gesture_detector_config_.touch_slop * 3;
1193 } 1200 }
1194 1201
1195 } // namespace ui 1202 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698