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

Unified Diff: ui/chromeos/touch_exploration_controller.cc

Issue 333623003: Added split tap to TouchExplorationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@VLOG
Patch Set: Created 6 years, 6 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 7028d787d95b0039a719776191f3fc23311d36c1..2f9af8811e7dc0f345bfa2b7c559dbd6cd7da815 100644
--- a/ui/chromeos/touch_exploration_controller.cc
+++ b/ui/chromeos/touch_exploration_controller.cc
@@ -130,6 +130,8 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
return InTouchExploration(touch_event, rewritten_event);
case PASSTHROUGH_MINUS_ONE:
return InPassthroughMinusOne(touch_event, rewritten_event);
+ case TE_SECOND_PRESS:
+ return InTESecondPress(touch_event, rewritten_event);
}
NOTREACHED();
@@ -244,10 +246,20 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) {
const ui::EventType type = event.type();
if (type == ui::ET_TOUCH_PRESSED) {
-
- // Ignore any additional fingers when we're already in touch exploration
- // mode. TODO(evy, lisayin): Support "split-tap" here instead.
- return ui::EVENT_REWRITE_DISCARD;
+ // Split-tap
+ initial_press_.reset(new TouchEvent(event));
+ if (tap_timer_.IsRunning())
+ tap_timer_.Stop();
+ ui::TouchEvent* rewritten_release_event =
dmazzoni 2014/06/13 05:52:38 this should be rewritten_touch_event
evy 2014/06/13 16:48:07 Done.
+ new ui::TouchEvent(ui::ET_TOUCH_PRESSED,
+ last_touch_exploration_location_,
+ event.touch_id(),
+ event.time_stamp());
+ rewritten_release_event->set_flags(event.flags());
+ rewritten_event->reset(rewritten_release_event);
+ state_ = TE_SECOND_PRESS;
+ VLOG_STATE();
+ return ui::EVENT_REWRITE_REWRITTEN;
} else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
if (current_touch_ids_.size() == 0)
ResetToNoFingersDown();
@@ -309,6 +321,50 @@ ui::EventRewriteStatus TouchExplorationController::InPassthroughMinusOne(
return ui::EVENT_REWRITE_CONTINUE;
}
+ui::EventRewriteStatus TouchExplorationController::InTESecondPress(
+ const ui::TouchEvent& event,
+ scoped_ptr<ui::Event>* rewritten_event) {
+ ui::EventType type = event.type();
+ gfx::PointF location = event.location_f();
+ if (tap_timer_.IsRunning())
dmazzoni 2014/06/13 05:52:38 This shouldn't be necessary - it's already done be
evy 2014/06/13 16:48:07 Yeah - right before the state change - thanks
+ tap_timer_.Stop();
+ if (type == ui::ET_TOUCH_PRESSED) {
+ return ui::EVENT_REWRITE_DISCARD;
+ } else if (type == ui::ET_TOUCH_MOVED) {
+ // Currently this is a discard, but could be something like rotor
+ // in the future.
+ return ui::EVENT_REWRITE_DISCARD;
+ } else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
+ // If the touch exploration finger is lifted, there is no option to return
+ // to touch explore anymore. The remaining finger acts as a pending
+ // tap or long tap for the last touch explore location.
+ if (event.touch_id() == 0){
dmazzoni 2014/06/13 05:52:38 I don't think you can assume the touch id is 0 for
evy 2014/06/13 16:48:07 Done. I changed last_touch_exploration_location to
+ state_ = DOUBLE_TAP_PRESSED;
+ VLOG_STATE();
+ return EVENT_REWRITE_DISCARD;
+ }
+
+ // Continue to rlease the touch only if the touch explore finger is the
dmazzoni 2014/06/13 05:52:38 rlease -> release
evy 2014/06/13 16:48:07 Done.
+ // only finger remaining.
+ if (current_touch_ids_.size() != 1)
+ return EVENT_REWRITE_DISCARD;
+
+ // Rewrite at location of last touch exploration.
+ ui::TouchEvent* rewritten_release_event = new ui::TouchEvent(
+ ui::ET_TOUCH_RELEASED,
+ last_touch_exploration_location_,
+ event.touch_id(),
dmazzoni 2014/06/13 05:52:38 This touch id might not be the same as the one tha
evy 2014/06/13 16:48:07 Done. I used initial_press_ instead - which should
+ event.time_stamp());
+ rewritten_release_event->set_flags(event.flags());
+ rewritten_event->reset(rewritten_release_event);
+ state_ = TOUCH_EXPLORATION;
+ VLOG_STATE();
+ return ui::EVENT_REWRITE_REWRITTEN;
+ }
+ NOTREACHED() << "Unexpected event type received.";
+ return ui::EVENT_REWRITE_CONTINUE;
+}
+
void TouchExplorationController::OnTapTimerFired() {
if (state_ != SINGLE_TAP_RELEASED && state_ != SINGLE_TAP_PRESSED)
return;
@@ -406,6 +462,8 @@ const char* TouchExplorationController::EnumStateToString(State state) {
return "TOUCH_EXPLORATION";
case PASSTHROUGH_MINUS_ONE:
return "PASSTHROUGH_MINUS_ONE";
+ case TE_SECOND_PRESS:
+ return "TE_SECOND_PRESS";
}
return "Not a state";
}

Powered by Google App Engine
This is Rietveld 408576698