Commit 7b85205d authored by Kevin Schoedel's avatar Kevin Schoedel Committed by Commit Bot

[chromecast] Remove touch exploration corner pass through

Ports the ash version change from crrev.com/580666

Bug: 869921, internal b/112073644
Test: manual
Change-Id: I85e68b53f13ff190d1f90f39f96f85f43699f20a
Reviewed-on: https://chromium-review.googlesource.com/1167651
Commit-Queue: Kevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582119}
parent f2f75f32
......@@ -121,13 +121,6 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
// this event under this new state.
}
if (passthrough_timer_.IsRunning() &&
event.time_stamp() - most_recent_press_timestamp_ >
gesture_detector_config_.longpress_timeout) {
passthrough_timer_.Stop();
OnPassthroughTimerFired();
}
const ui::EventType type = touch_event.type();
const int touch_id = touch_event.pointer_details().id;
......@@ -250,9 +243,6 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
case ONE_FINGER_PASSTHROUGH:
status = InOneFingerPassthrough(touch_event_dip, rewritten_event);
break;
case CORNER_PASSTHROUGH:
status = InCornerPassthrough(touch_event_dip, rewritten_event);
break;
case WAIT_FOR_NO_FINGERS:
status = InWaitForNoFingers(touch_event_dip, rewritten_event);
break;
......@@ -283,24 +273,9 @@ ui::EventRewriteStatus TouchExplorationController::InNoFingersDown(
return ui::EVENT_REWRITE_CONTINUE;
}
int location = FindEdgesWithinInset(event.location(), kSlopDistanceFromEdge);
// If the press was at a corner, the user might go into corner passthrough
// instead.
bool in_a_bottom_corner =
(BOTTOM_LEFT_CORNER == location) || (BOTTOM_RIGHT_CORNER == location);
if (in_a_bottom_corner) {
passthrough_timer_.Start(
FROM_HERE, gesture_detector_config_.longpress_timeout, this,
&TouchExplorationController::OnPassthroughTimerFired);
} else {
// If the user enters the screen from the edge then send an earcon,
// and enter passthrough mode so that the system gesture handle can
// handle it.
int edge = FindEdgesWithinInset(event.location(), kLeavingScreenEdge);
if (edge != NO_EDGE) {
accessibility_sound_player_->PlayEnterScreenEarcon();
}
}
int edge = FindEdgesWithinInset(event.location(), kLeavingScreenEdge);
if (edge != NO_EDGE)
accessibility_sound_player_->PlayEnterScreenEarcon();
initial_press_ = std::make_unique<ui::TouchEvent>(event);
most_recent_press_timestamp_ = initial_press_->time_stamp();
......@@ -316,32 +291,11 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
std::unique_ptr<ui::Event>* rewritten_event) {
const ui::EventType type = event.type();
int location = FindEdgesWithinInset(event.location(), kMaxDistanceFromEdge);
bool in_a_bottom_corner =
(location == BOTTOM_LEFT_CORNER) || (location == BOTTOM_RIGHT_CORNER);
// If the event is from the initial press and the location is no longer in the
// corner, then we are not waiting for a corner passthrough anymore.
if (event.pointer_details().id == initial_press_->pointer_details().id &&
!in_a_bottom_corner) {
if (passthrough_timer_.IsRunning()) {
passthrough_timer_.Stop();
// Since the long press timer has been running, it is possible that the
// tap timer has timed out before the long press timer has. If the tap
// timer timeout has elapsed, then fire the tap timer.
if (event.time_stamp() - most_recent_press_timestamp_ >
gesture_detector_config_.double_tap_timeout) {
OnTapTimerFired();
}
}
}
if (type == ui::ET_TOUCH_PRESSED) {
initial_presses_[event.pointer_details().id] = event.location();
SET_STATE(TWO_FINGER_TAP);
return ui::EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
if (passthrough_timer_.IsRunning())
passthrough_timer_.Stop();
if (current_touch_ids_.size() == 0 &&
event.pointer_details().id == initial_press_->pointer_details().id) {
MaybeSendSimulatedTapInLiftActivationBounds(event);
......@@ -523,45 +477,6 @@ ui::EventRewriteStatus TouchExplorationController::InGestureInProgress(
return ui::EVENT_REWRITE_DISCARD;
}
ui::EventRewriteStatus TouchExplorationController::InCornerPassthrough(
const ui::TouchEvent& event,
std::unique_ptr<ui::Event>* rewritten_event) {
ui::EventType type = event.type();
// If the first finger has left the corner, then exit passthrough.
if (event.pointer_details().id == initial_press_->pointer_details().id) {
int edges =
FindEdgesWithinInset(event.location(), kSlopDistanceFromEdge);
bool in_a_bottom_corner =
(edges == BOTTOM_LEFT_CORNER) || (edges == BOTTOM_RIGHT_CORNER);
if (type == ui::ET_TOUCH_MOVED && in_a_bottom_corner)
return ui::EVENT_REWRITE_DISCARD;
accessibility_sound_player_->PlayPassthroughEndEarcon();
if (current_touch_ids_.size() == 0) {
SET_STATE(NO_FINGERS_DOWN);
return ui::EVENT_REWRITE_DISCARD;
}
SET_STATE(WAIT_FOR_NO_FINGERS);
return ui::EVENT_REWRITE_DISCARD;
}
// |event| locations are in DIP; see |RewriteEvent|. We need to dispatch
// screen coordinates.
gfx::PointF location_f(ConvertDIPToScreenInPixels(event.location_f()));
std::unique_ptr<ui::TouchEvent> new_event(new ui::TouchEvent(
type, gfx::Point(), event.time_stamp(), event.pointer_details()));
new_event->set_location_f(location_f);
new_event->set_root_location_f(location_f);
new_event->set_flags(event.flags());
*rewritten_event = std::move(new_event);
if (current_touch_ids_.size() == 0)
SET_STATE(NO_FINGERS_DOWN);
return ui::EVENT_REWRITE_REWRITTEN;
}
ui::EventRewriteStatus TouchExplorationController::InOneFingerPassthrough(
const ui::TouchEvent& event,
std::unique_ptr<ui::Event>* rewritten_event) {
......@@ -773,9 +688,6 @@ void TouchExplorationController::OnTapTimerFired() {
return;
}
case SINGLE_TAP_PRESSED:
if (passthrough_timer_.IsRunning())
return;
FALLTHROUGH;
case GESTURE_IN_PROGRESS:
// If only one finger is down, go into touch exploration.
if (current_touch_ids_.size() == 1) {
......@@ -802,30 +714,6 @@ void TouchExplorationController::OnTapTimerFired() {
anchor_point_state_ = ANCHOR_POINT_FROM_TOUCH_EXPLORATION;
}
void TouchExplorationController::OnPassthroughTimerFired() {
// The passthrough timer will only fire if if the user has held a finger in
// one of the passthrough corners for the duration of the passthrough timeout.
// Check that initial press isn't null. Also a check that if the initial
// corner press was released, then it should not be in corner passthrough.
if (!initial_press_ ||
touch_locations_.find(initial_press_->pointer_details().id) !=
touch_locations_.end()) {
}
gfx::Point location =
ToRoundedPoint(touch_locations_[initial_press_->pointer_details().id]);
int corner = FindEdgesWithinInset(location, kSlopDistanceFromEdge);
if (corner != BOTTOM_LEFT_CORNER && corner != BOTTOM_RIGHT_CORNER)
return;
if (sound_timer_.IsRunning())
sound_timer_.Stop();
accessibility_sound_player_->PlayPassthroughEarcon();
SET_STATE(CORNER_PASSTHROUGH);
return;
}
void TouchExplorationController::DispatchEvent(ui::Event* event) {
SetTouchAccessibilityFlag(event);
if (event->IsLocatedEvent()) {
......@@ -1061,7 +949,6 @@ void TouchExplorationController::SetState(State new_state,
case TOUCH_EXPLORATION:
case TOUCH_EXPLORE_SECOND_PRESS:
case ONE_FINGER_PASSTHROUGH:
case CORNER_PASSTHROUGH:
case WAIT_FOR_NO_FINGERS:
if (gesture_provider_.get())
gesture_provider_.reset(NULL);
......@@ -1138,8 +1025,6 @@ const char* TouchExplorationController::EnumStateToString(State state) {
return "GESTURE_IN_PROGRESS";
case TOUCH_EXPLORE_SECOND_PRESS:
return "TOUCH_EXPLORE_SECOND_PRESS";
case CORNER_PASSTHROUGH:
return "CORNER_PASSTHROUGH";
case ONE_FINGER_PASSTHROUGH:
return "ONE_FINGER_PASSTHROUGH";
case WAIT_FOR_NO_FINGERS:
......
......@@ -206,9 +206,6 @@ class TouchExplorationController : public ui::EventRewriter,
ui::EventRewriteStatus InTouchExploration(
const ui::TouchEvent& event,
std::unique_ptr<ui::Event>* rewritten_event);
ui::EventRewriteStatus InCornerPassthrough(
const ui::TouchEvent& event,
std::unique_ptr<ui::Event>* rewritten_event);
ui::EventRewriteStatus InOneFingerPassthrough(
const ui::TouchEvent& event,
std::unique_ptr<ui::Event>* rewritten_event);
......@@ -235,13 +232,6 @@ class TouchExplorationController : public ui::EventRewriter,
void StartTapTimer();
void OnTapTimerFired();
// This timer is started every timer we get the first press event and the
// finger is in the corner of the screen.
// It fires after the corner passthrough delay elapses. If the
// user is still in the corner by the time this timer fires, all subsequent
// fingers added on the screen will be passed through.
void OnPassthroughTimerFired();
// Dispatch a new event outside of the event rewriting flow.
void DispatchEvent(ui::Event* event);
......@@ -369,11 +359,6 @@ class TouchExplorationController : public ui::EventRewriter,
// all fingers.
ONE_FINGER_PASSTHROUGH,
// If the user has pressed and held down the left corner past long press,
// then as long as they are holding the corner, all subsequent fingers
// registered will be in passthrough.
CORNER_PASSTHROUGH,
// If the user added another finger in SINGLE_TAP_PRESSED, or if the user
// has multiple fingers fingers down in any other state between
// passthrough, touch exploration, and gestures, they must release
......@@ -400,8 +385,6 @@ class TouchExplorationController : public ui::EventRewriter,
TOP_EDGE = 1 << 1,
LEFT_EDGE = 1 << 2,
BOTTOM_EDGE = 1 << 3,
BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE,
BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE,
};
// Given a point, if it is within the given inset of an edge, returns the
......@@ -476,9 +459,6 @@ class TouchExplorationController : public ui::EventRewriter,
// A timer that fires after the double-tap delay.
base::OneShotTimer tap_timer_;
// A timer that fires to enter passthrough.
base::OneShotTimer passthrough_timer_;
// A timer to fire an indicating sound when sliding to change volume.
base::RepeatingTimer sound_timer_;
......
......@@ -137,12 +137,6 @@ class TouchExplorationControllerTestApi {
touch_exploration_controller_->OnTapTimerFired();
}
void CallPassthroughTimerNowForTesting() {
DCHECK(touch_exploration_controller_->passthrough_timer_.IsRunning());
touch_exploration_controller_->passthrough_timer_.Stop();
touch_exploration_controller_->OnPassthroughTimerFired();
}
void CallTapTimerNowIfRunningForTesting() {
if (touch_exploration_controller_->tap_timer_.IsRunning()) {
touch_exploration_controller_->tap_timer_.Stop();
......@@ -164,10 +158,6 @@ class TouchExplorationControllerTestApi {
return touch_exploration_controller_->state_ ==
touch_exploration_controller_->TWO_FINGER_TAP;
}
bool IsInCornerPassthroughStateForTesting() const {
return touch_exploration_controller_->state_ ==
touch_exploration_controller_->CORNER_PASSTHROUGH;
}
gfx::Rect BoundsOfRootWindowInDIPForTesting() const {
return touch_exploration_controller_->root_window_->GetBoundsInScreen();
......@@ -297,11 +287,6 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
touch_exploration_controller_->CallTapTimerNowForTesting();
}
void AdvanceSimulatedTimePastPassthroughDelay() {
simulated_clock_.Advance(base::TimeDelta::FromMilliseconds(1000));
touch_exploration_controller_->CallPassthroughTimerNowForTesting();
}
void AdvanceSimulatedTimePastPotentialTapDelay() {
simulated_clock_.Advance(base::TimeDelta::FromMilliseconds(1000));
touch_exploration_controller_->CallTapTimerNowIfRunningForTesting();
......@@ -334,50 +319,6 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
EXPECT_TRUE(IsInTouchToMouseMode());
}
// Checks that Corner Passthrough is working. Assumes that corner is the
// bottom left corner or the bottom right corner.
void AssertCornerPassthroughWorking(gfx::Point corner) {
ASSERT_EQ(0U, accessibility_sound_player_.NumPassthroughSounds());
ui::TouchEvent first_press(
ui::ET_TOUCH_PRESSED, corner, Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
generator_->Dispatch(&first_press);
AdvanceSimulatedTimePastPassthroughDelay();
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_FALSE(IsInTouchToMouseMode());
EXPECT_TRUE(IsInCornerPassthroughState());
gfx::Rect window = BoundsOfRootWindowInDIP();
// The following events should be passed through.
gfx::Point passthrough(window.right() / 2, window.bottom() / 2);
ui::TouchEvent passthrough_press(
ui::ET_TOUCH_PRESSED, passthrough, Now(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
ASSERT_EQ(1U, accessibility_sound_player_.NumPassthroughSounds());
generator_->Dispatch(&passthrough_press);
generator_->ReleaseTouchId(1);
generator_->PressTouchId(1);
EXPECT_FALSE(IsInGestureInProgressState());
EXPECT_TRUE(IsInCornerPassthroughState());
std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(3U, captured_events.size());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type());
generator_->ReleaseTouchId(1);
ClearCapturedEvents();
generator_->ReleaseTouchId(0);
captured_events = GetCapturedLocatedEvents();
ASSERT_EQ(0U, captured_events.size());
EXPECT_FALSE(IsInTouchToMouseMode());
EXPECT_FALSE(IsInCornerPassthroughState());
ClearCapturedEvents();
}
bool IsInTouchToMouseMode() {
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(root_window());
......@@ -398,11 +339,6 @@ class TouchExplorationTest : public aura::test::AuraTestBase {
return touch_exploration_controller_->IsInTwoFingerTapStateForTesting();
}
bool IsInCornerPassthroughState() {
return touch_exploration_controller_
->IsInCornerPassthroughStateForTesting();
}
gfx::Rect BoundsOfRootWindowInDIP() {
return touch_exploration_controller_->BoundsOfRootWindowInDIPForTesting();
}
......@@ -1733,32 +1669,6 @@ TEST_F(TouchExplorationTest, TwoFingerTapAndMoveSecondFinger) {
EXPECT_FALSE(IsInTwoFingerTapState());
}
// Corner passthrough should turn on if the user first holds down on either the
// right or left corner past a delay and then places a finger anywhere else on
// the screen.
TEST_F(TouchExplorationTest, ActivateLeftCornerPassthrough) {
SwitchTouchExplorationMode(true);
gfx::Rect window = BoundsOfRootWindowInDIP();
gfx::Point left_corner(
(GetLeavingDistanceFromEdge() + GetMaxDistanceFromEdge()) / 2,
window.bottom() -
(GetLeavingDistanceFromEdge() + GetMaxDistanceFromEdge()) / 2);
AssertCornerPassthroughWorking(left_corner);
}
TEST_F(TouchExplorationTest, ActivateRightCornerPassthrough) {
SwitchTouchExplorationMode(true);
gfx::Rect window = BoundsOfRootWindowInDIP();
gfx::Point right_corner(
window.right() -
(GetLeavingDistanceFromEdge() + GetMaxDistanceFromEdge()) / 2,
window.bottom() -
(GetLeavingDistanceFromEdge() + GetMaxDistanceFromEdge()) / 2);
AssertCornerPassthroughWorking(right_corner);
}
// Earcons should play if the user slides off the screen or enters the screen
// from the edge.
TEST_F(TouchExplorationTest, EnterEarconPlays) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment