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

Unified Diff: ui/chromeos/touch_exploration_controller.cc

Issue 420073003: Two Finger Tap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase off master Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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..c8ce0b64165c836fbc2500b4321b6b2e29d8d054 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;
aboxhall 2014/08/06 18:30:00 Does this have any implications for multi-finger s
lisayin 2014/08/06 20:41:35 Once we need to merge the two, we'll have a slop c
+ }
// 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) {
aboxhall 2014/08/06 18:30:00 And, does this have any implications for multi-fin
evy 2014/08/06 18:33:03 Yeah, whoever finishes last gets to add the change
+ state_ = WAIT_FOR_ONE_FINGER;
+ 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,8 @@ 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";
}

Powered by Google App Engine
This is Rietveld 408576698