Chromium Code Reviews| 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/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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 root_window_->GetHost()->ConvertDIPToScreenInPixels(&native_point); | 65 root_window_->GetHost()->ConvertDIPToScreenInPixels(&native_point); |
| 66 | 66 |
| 67 anchor_point_ = gfx::PointF(native_point.x(), native_point.y()); | 67 anchor_point_ = gfx::PointF(native_point.x(), native_point.y()); |
| 68 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET; | 68 anchor_point_state_ = ANCHOR_POINT_EXPLICITLY_SET; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) { | 71 void TouchExplorationController::SetExcludeBounds(const gfx::Rect& bounds) { |
| 72 exclude_bounds_ = bounds; | 72 exclude_bounds_ = bounds; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void TouchExplorationController::SetLiftActivationBounds( | |
| 76 const gfx::Rect& bounds) { | |
| 77 lift_activation_bounds_ = bounds; | |
| 78 } | |
| 79 | |
| 75 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 80 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| 76 const ui::Event& event, | 81 const ui::Event& event, |
| 77 std::unique_ptr<ui::Event>* rewritten_event) { | 82 std::unique_ptr<ui::Event>* rewritten_event) { |
| 78 if (!event.IsTouchEvent()) { | 83 if (!event.IsTouchEvent()) { |
| 79 if (event.IsKeyEvent()) { | 84 if (event.IsKeyEvent()) { |
| 80 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 85 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 81 VLOG(1) << "\nKeyboard event: " << key_event.GetName() | 86 VLOG(1) << "\nKeyboard event: " << key_event.GetName() |
| 82 << "\n Key code: " << key_event.key_code() | 87 << "\n Key code: " << key_event.key_code() |
| 83 << ", Flags: " << key_event.flags() | 88 << ", Flags: " << key_event.flags() |
| 84 << ", Is char: " << key_event.is_char(); | 89 << ", Is char: " << key_event.is_char(); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 const ui::EventType type = event.type(); | 471 const ui::EventType type = event.type(); |
| 467 if (type == ui::ET_TOUCH_PRESSED) { | 472 if (type == ui::ET_TOUCH_PRESSED) { |
| 468 // Enter split-tap mode. | 473 // Enter split-tap mode. |
| 469 initial_press_.reset(new TouchEvent(event)); | 474 initial_press_.reset(new TouchEvent(event)); |
| 470 tap_timer_.Stop(); | 475 tap_timer_.Stop(); |
| 471 SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); | 476 SET_STATE(TOUCH_EXPLORE_SECOND_PRESS); |
| 472 return ui::EVENT_REWRITE_DISCARD; | 477 return ui::EVENT_REWRITE_DISCARD; |
| 473 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { | 478 } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) { |
| 474 initial_press_.reset(new TouchEvent(event)); | 479 initial_press_.reset(new TouchEvent(event)); |
| 475 StartTapTimer(); | 480 StartTapTimer(); |
| 481 if (!lift_activation_bounds_.IsEmpty()) { | |
| 482 gfx::Point location = event.location(); | |
| 483 root_window_->GetHost()->ConvertScreenInPixelsToDIP(&location); | |
| 484 if (lift_activation_bounds_.Contains(location)) | |
| 485 DispatchSynthesizedTap(); | |
|
dmazzoni
2017/05/15 21:24:34
I think you'll want to call it from more than one
David Tseng
2017/05/16 16:07:34
Sending a click event maps to forceClickOnCurrentI
David Tseng
2017/05/16 16:07:34
Isn't a quick tap just pass through mode? i.e. it
| |
| 486 } | |
| 476 SET_STATE(TOUCH_EXPLORE_RELEASED); | 487 SET_STATE(TOUCH_EXPLORE_RELEASED); |
| 477 } else if (type != ui::ET_TOUCH_MOVED) { | 488 } else if (type != ui::ET_TOUCH_MOVED) { |
| 478 NOTREACHED(); | 489 NOTREACHED(); |
| 479 return ui::EVENT_REWRITE_CONTINUE; | 490 return ui::EVENT_REWRITE_CONTINUE; |
| 480 } | 491 } |
| 481 | 492 |
| 482 // Rewrite as a mouse-move event. | 493 // Rewrite as a mouse-move event. |
| 483 *rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags()); | 494 *rewritten_event = CreateMouseMoveEvent(event.location_f(), event.flags()); |
| 484 last_touch_exploration_.reset(new TouchEvent(event)); | 495 last_touch_exploration_.reset(new TouchEvent(event)); |
| 485 if (anchor_point_state_ != ANCHOR_POINT_EXPLICITLY_SET) | 496 if (anchor_point_state_ != ANCHOR_POINT_EXPLICITLY_SET) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 637 } | 648 } |
| 638 | 649 |
| 639 void TouchExplorationController::SendSimulatedClick() { | 650 void TouchExplorationController::SendSimulatedClick() { |
| 640 // If we got an anchor point from ChromeVox, send a double-tap gesture | 651 // If we got an anchor point from ChromeVox, send a double-tap gesture |
| 641 // and let ChromeVox handle the click. | 652 // and let ChromeVox handle the click. |
| 642 if (anchor_point_state_ == ANCHOR_POINT_EXPLICITLY_SET) { | 653 if (anchor_point_state_ == ANCHOR_POINT_EXPLICITLY_SET) { |
| 643 delegate_->HandleAccessibilityGesture(ui::AX_GESTURE_CLICK); | 654 delegate_->HandleAccessibilityGesture(ui::AX_GESTURE_CLICK); |
| 644 return; | 655 return; |
| 645 } | 656 } |
| 646 | 657 |
| 647 // If we don't have an anchor point, we can't send a simulated click. | 658 DispatchSynthesizedTap(); |
| 659 } | |
| 660 | |
| 661 void TouchExplorationController::DispatchSynthesizedTap() { | |
|
dmazzoni
2017/05/15 21:24:35
Rather than splitting SendSimulatedClick into two
David Tseng
2017/05/16 16:07:34
Ditto.
| |
| 648 if (anchor_point_state_ == ANCHOR_POINT_NONE) | 662 if (anchor_point_state_ == ANCHOR_POINT_NONE) |
| 649 return; | 663 return; |
| 650 | 664 |
| 651 // Otherwise send a simulated press/release at the anchor point. | |
| 652 std::unique_ptr<ui::TouchEvent> touch_press; | 665 std::unique_ptr<ui::TouchEvent> touch_press; |
| 653 touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), | 666 touch_press.reset(new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(), |
| 654 Now(), | 667 Now(), |
| 655 initial_press_->pointer_details())); | 668 initial_press_->pointer_details())); |
| 656 touch_press->set_location_f(anchor_point_); | 669 touch_press->set_location_f(anchor_point_); |
| 657 touch_press->set_root_location_f(anchor_point_); | 670 touch_press->set_root_location_f(anchor_point_); |
| 658 DispatchEvent(touch_press.get()); | 671 DispatchEvent(touch_press.get()); |
| 659 | 672 |
| 660 std::unique_ptr<ui::TouchEvent> touch_release; | 673 std::unique_ptr<ui::TouchEvent> touch_release; |
| 661 touch_release.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), | 674 touch_release.reset(new ui::TouchEvent(ui::ET_TOUCH_RELEASED, gfx::Point(), |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 // Otherwise wait for all fingers to be lifted. | 811 // Otherwise wait for all fingers to be lifted. |
| 799 SET_STATE(WAIT_FOR_NO_FINGERS); | 812 SET_STATE(WAIT_FOR_NO_FINGERS); |
| 800 return; | 813 return; |
| 801 case TWO_FINGER_TAP: | 814 case TWO_FINGER_TAP: |
| 802 SET_STATE(WAIT_FOR_NO_FINGERS); | 815 SET_STATE(WAIT_FOR_NO_FINGERS); |
| 803 break; | 816 break; |
| 804 default: | 817 default: |
| 805 return; | 818 return; |
| 806 } | 819 } |
| 807 EnterTouchToMouseMode(); | 820 EnterTouchToMouseMode(); |
| 808 std::unique_ptr<ui::Event> mouse_move = CreateMouseMoveEvent( | 821 std::unique_ptr<ui::Event> mouse_move = CreateMouseMoveEvent( |
|
dmazzoni
2017/05/15 21:24:34
Here's the other place where you'll want to send
a
| |
| 809 initial_press_->location_f(), initial_press_->flags()); | 822 initial_press_->location_f(), initial_press_->flags()); |
| 810 DispatchEvent(mouse_move.get()); | 823 DispatchEvent(mouse_move.get()); |
| 811 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); | 824 last_touch_exploration_.reset(new TouchEvent(*initial_press_)); |
| 812 anchor_point_ = last_touch_exploration_->location_f(); | 825 anchor_point_ = last_touch_exploration_->location_f(); |
| 813 anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION; | 826 anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION; |
| 814 } | 827 } |
| 815 | 828 |
| 816 void TouchExplorationController::OnPassthroughTimerFired() { | 829 void TouchExplorationController::OnPassthroughTimerFired() { |
| 817 // The passthrough timer will only fire if if the user has held a finger in | 830 // The passthrough timer will only fire if if the user has held a finger in |
| 818 // one of the passthrough corners for the duration of the passthrough timeout. | 831 // one of the passthrough corners for the duration of the passthrough timeout. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1192 return "TWO_FINGER_TAP"; | 1205 return "TWO_FINGER_TAP"; |
| 1193 } | 1206 } |
| 1194 return "Not a state"; | 1207 return "Not a state"; |
| 1195 } | 1208 } |
| 1196 | 1209 |
| 1197 float TouchExplorationController::GetSplitTapTouchSlop() { | 1210 float TouchExplorationController::GetSplitTapTouchSlop() { |
| 1198 return gesture_detector_config_.touch_slop * 3; | 1211 return gesture_detector_config_.touch_slop * 3; |
| 1199 } | 1212 } |
| 1200 | 1213 |
| 1201 } // namespace ui | 1214 } // namespace ui |
| OLD | NEW |