Chromium Code Reviews| Index: ui/chromeos/touch_exploration_controller.cc |
| diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc |
| index 3670f1e948f213908d1884d9f844eacf35916a5c..b5cb78e61bb98535a7a4a3df3fce2b394dc9c3cc 100644 |
| --- a/ui/chromeos/touch_exploration_controller.cc |
| +++ b/ui/chromeos/touch_exploration_controller.cc |
| @@ -27,6 +27,10 @@ const base::TimeDelta kSoundDelay = base::TimeDelta::FromMilliseconds(150); |
| // In ChromeOS, VKEY_LWIN is synonymous for the search key. |
| const ui::KeyboardCode kChromeOSSearchKey = ui::VKEY_LWIN; |
| + |
| +// Delay to indicate that a two finger tap has occured. |
| +const base::TimeDelta kTwoFingerTap = base::TimeDelta::FromMilliseconds(50); |
| + |
| } // namespace |
| TouchExplorationController::TouchExplorationController( |
| @@ -134,6 +138,8 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| return InOneFingerPassthrough(touch_event, rewritten_event); |
| case WAIT_FOR_ONE_FINGER: |
| return InWaitForOneFinger(touch_event, rewritten_event); |
| + case TWO_FINGER_TAP: |
| + return InTwoFingerTap(touch_event, rewritten_event); |
| } |
| NOTREACHED(); |
| return ui::EVENT_REWRITE_CONTINUE; |
| @@ -168,6 +174,11 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed( |
| const ui::EventType type = event.type(); |
| if (type == ui::ET_TOUCH_PRESSED) { |
| + if ((event.time_stamp() - initial_press_->time_stamp()) < kTwoFingerTap) { |
| + state_ = TWO_FINGER_TAP; |
| + VLOG_STATE(); |
| + return EVENT_REWRITE_DISCARD; |
| + } |
| // TODO (evy, lisayin) : add support for multifinger swipes. |
| // For now, we wait for there to be only one finger down again. |
| state_ = WAIT_FOR_ONE_FINGER; |
| @@ -549,6 +560,33 @@ ui::EventRewriteStatus TouchExplorationController::InSlideGesture( |
| return ui::EVENT_REWRITE_DISCARD; |
| } |
| +ui::EventRewriteStatus TouchExplorationController::InTwoFingerTap( |
| + const ui::TouchEvent& event, |
| + scoped_ptr<ui::Event>* rewritten_event) { |
| + ui::EventType type = event.type(); |
| + if (type == ui::ET_TOUCH_PRESSED) { |
| + state_ = WAIT_FOR_ONE_FINGER; |
|
dmazzoni
2014/07/31 20:44:43
Do we really want to wait for one finger?
I'd pre
lisayin
2014/07/31 21:43:27
I agree, but Evy is writing WAIT_FOR_NO_FINGERS_DO
|
| + VLOG_STATE(); |
| + return ui::EVENT_REWRITE_DISCARD; |
| + } |
| + |
| + if (current_touch_ids_.size() != 0) |
| + return ui::EVENT_REWRITE_DISCARD; |
| + |
| + if (type == ui::ET_TOUCH_RELEASED) { |
| + ui::KeyEvent control_down( |
| + ui::ET_KEY_PRESSED, ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN); |
| + ui::KeyEvent control_up(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, ui::EF_NONE); |
| + |
| + DispatchEvent(&control_down); |
| + DispatchEvent(&control_up); |
| + |
| + ResetToNoFingersDown(); |
| + return ui::EVENT_REWRITE_DISCARD; |
| + } |
| + return ui::EVENT_REWRITE_DISCARD; |
| +} |
| + |
| base::TimeDelta TouchExplorationController::Now() { |
| if (tick_clock_) { |
| // This is the same as what EventTimeForNow() does, but here we do it |
| @@ -595,6 +633,10 @@ void TouchExplorationController::OnTapTimerFired() { |
| state_ = TOUCH_EXPLORATION; |
| VLOG_STATE(); |
| break; |
| + case TWO_FINGER_TAP: |
| + state_ = WAIT_FOR_ONE_FINGER; |
| + VLOG_STATE(); |
| + break; |
| default: |
| return; |
| } |
| @@ -875,6 +917,9 @@ const char* TouchExplorationController::EnumStateToString(State state) { |
| return "ONE_FINGER_PASSTHROUGH"; |
| case WAIT_FOR_ONE_FINGER: |
| return "WAIT_FOR_ONE_FINGER"; |
| + case TWO_FINGER_TAP: |
| + return "TWO_FINGER_TAP"; |
| + |
| } |
| return "Not a state"; |
| } |