Commit 0421fed4 authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Add enable_side_gesture_pass_thru feature flag

This feature flag alters chromecast's handling of
gestures that originate from the edges of the screne.
When enabled, it is assumed an external side swipe gesture
detector is installed handling touch events downstream.
The touch exploration controller enters pass through
mode when touch events originate from the screen edges.
The side swipe detector is also not installed.

Bug: None
Test: Manual, display assistant
Change-Id: I23d35a322c09933fde3ac6989a90a692fb40e221
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1793249Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697236}
parent ea9ac612
...@@ -155,6 +155,9 @@ const base::Feature kEnableGeneralAudienceBrowsing{ ...@@ -155,6 +155,9 @@ const base::Feature kEnableGeneralAudienceBrowsing{
const base::Feature kUseQueryableDataBackend{"use_queryable_data_backend", const base::Feature kUseQueryableDataBackend{"use_queryable_data_backend",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kEnableSideGesturePassThrough{
"enable_side_gesture_pass_through", base::FEATURE_DISABLED_BY_DEFAULT};
// End Chromecast Feature definitions. // End Chromecast Feature definitions.
const base::Feature* kFeatures[] = { const base::Feature* kFeatures[] = {
&kAllowUserMediaAccess, &kAllowUserMediaAccess,
...@@ -164,6 +167,7 @@ const base::Feature* kFeatures[] = { ...@@ -164,6 +167,7 @@ const base::Feature* kFeatures[] = {
&kDisableIdleSocketsCloseOnMemoryPressure, &kDisableIdleSocketsCloseOnMemoryPressure,
&kEnableGeneralAudienceBrowsing, &kEnableGeneralAudienceBrowsing,
&kUseQueryableDataBackend, &kUseQueryableDataBackend,
&kEnableSideGesturePassThrough,
}; };
// An iterator for a base::DictionaryValue. Use an alias for brevity in loops. // An iterator for a base::DictionaryValue. Use an alias for brevity in loops.
......
...@@ -30,6 +30,7 @@ extern const base::Feature kSingleBuffer; ...@@ -30,6 +30,7 @@ extern const base::Feature kSingleBuffer;
extern const base::Feature kDisableIdleSocketsCloseOnMemoryPressure; extern const base::Feature kDisableIdleSocketsCloseOnMemoryPressure;
extern const base::Feature kEnableGeneralAudienceBrowsing; extern const base::Feature kEnableGeneralAudienceBrowsing;
extern const base::Feature kUseQueryableDataBackend; extern const base::Feature kUseQueryableDataBackend;
extern const base::Feature kEnableSideGesturePassThrough;
// Get an iterable list of all of the cast features for checking all features as // Get an iterable list of all of the cast features for checking all features as
// a collection. // a collection.
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "chromecast/base/cast_features.h"
#include "chromecast/base/chromecast_switches.h"
#include "ui/aura/client/cursor_client.h" #include "ui/aura/client/cursor_client.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
...@@ -29,9 +31,21 @@ ...@@ -29,9 +31,21 @@
VlogEvent(event, __func__) VlogEvent(event, __func__)
namespace chromecast { namespace chromecast {
namespace shell {
namespace { namespace {
// TODO(rmrossi): Unify with identical values in SideSwipeDetector.
// The number of pixels from the very left or right of the screen to consider as
// a valid origin for the left or right swipe gesture.
constexpr int kDefaultSideGestureStartWidth = 35;
// The number of pixels from the very top or bottom of the screen to consider as
// a valid origin for the top or bottom swipe gesture.
constexpr int kDefaultSideGestureStartHeight = 35;
} // namespace
namespace shell {
void SetTouchAccessibilityFlag(ui::Event* event) { void SetTouchAccessibilityFlag(ui::Event* event) {
// This flag is used to identify mouse move events that were generated from // This flag is used to identify mouse move events that were generated from
...@@ -39,8 +53,6 @@ void SetTouchAccessibilityFlag(ui::Event* event) { ...@@ -39,8 +53,6 @@ void SetTouchAccessibilityFlag(ui::Event* event) {
event->set_flags(event->flags() | ui::EF_TOUCH_ACCESSIBILITY); event->set_flags(event->flags() | ui::EF_TOUCH_ACCESSIBILITY);
} }
} // namespace
TouchExplorationController::TouchExplorationController( TouchExplorationController::TouchExplorationController(
aura::Window* root_window, aura::Window* root_window,
TouchExplorationControllerDelegate* delegate, TouchExplorationControllerDelegate* delegate,
...@@ -52,7 +64,14 @@ TouchExplorationController::TouchExplorationController( ...@@ -52,7 +64,14 @@ TouchExplorationController::TouchExplorationController(
anchor_point_state_(ANCHOR_POINT_NONE), anchor_point_state_(ANCHOR_POINT_NONE),
gesture_provider_(new ui::GestureProviderAura(this, this)), gesture_provider_(new ui::GestureProviderAura(this, this)),
prev_state_(NO_FINGERS_DOWN), prev_state_(NO_FINGERS_DOWN),
DVLOG_on_(true) {} DVLOG_on_(true),
gesture_start_width_(GetSwitchValueInt(switches::kSystemGestureStartWidth,
kDefaultSideGestureStartWidth)),
gesture_start_height_(
GetSwitchValueInt(switches::kSystemGestureStartHeight,
kDefaultSideGestureStartHeight)),
side_gesture_pass_through_(
chromecast::IsFeatureEnabled(kEnableSideGesturePassThrough)) {}
TouchExplorationController::~TouchExplorationController() {} TouchExplorationController::~TouchExplorationController() {}
...@@ -172,10 +191,21 @@ ui::EventDispatchDetails TouchExplorationController::RewriteEvent( ...@@ -172,10 +191,21 @@ ui::EventDispatchDetails TouchExplorationController::RewriteEvent(
} }
DVLOG_EVENT(touch_event); DVLOG_EVENT(touch_event);
// Enter pass through mode when side gestures are set to pass-through.
if (side_gesture_pass_through_ && type == ui::ET_TOUCH_PRESSED &&
FindEdgesWithinInset(location, gesture_start_width_,
gesture_start_height_) != NO_EDGE) {
SET_STATE(ONE_FINGER_PASSTHROUGH);
initial_press_ = std::make_unique<ui::TouchEvent>(touch_event);
last_unused_finger_event_.reset(new ui::TouchEvent(touch_event));
return SendEvent(continuation, &event);
}
// In order to avoid accidentally double tapping when moving off the edge // In order to avoid accidentally double tapping when moving off the edge
// of the screen, the state will be rewritten to NoFingersDown. // of the screen, the state will be rewritten to NoFingersDown.
if ((type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) && if ((type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) &&
FindEdgesWithinInset(location, kLeavingScreenEdge) != NO_EDGE) { FindEdgesWithinInset(location, kLeavingScreenEdge, kLeavingScreenEdge) !=
NO_EDGE) {
if (DVLOG_on_) if (DVLOG_on_)
DVLOG(1) << "Leaving screen"; DVLOG(1) << "Leaving screen";
...@@ -851,9 +881,10 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { ...@@ -851,9 +881,10 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) {
} }
int TouchExplorationController::FindEdgesWithinInset(gfx::Point point_dip, int TouchExplorationController::FindEdgesWithinInset(gfx::Point point_dip,
float inset) { float horiz_inset,
float vert_inset) {
gfx::RectF inner_bounds_dip(root_window_->bounds()); gfx::RectF inner_bounds_dip(root_window_->bounds());
inner_bounds_dip.Inset(inset, inset); inner_bounds_dip.Inset(horiz_inset, vert_inset);
// Bitwise manipulation in order to determine where on the screen the point // Bitwise manipulation in order to determine where on the screen the point
// lies. If more than one bit is turned on, then it is a corner where the two // lies. If more than one bit is turned on, then it is a corner where the two
......
...@@ -282,7 +282,6 @@ class TouchExplorationController : public ui::EventRewriter, ...@@ -282,7 +282,6 @@ class TouchExplorationController : public ui::EventRewriter,
// Within this many dips of the screen edge, the release event generated will // Within this many dips of the screen edge, the release event generated will
// reset the state to NoFingersDown. // reset the state to NoFingersDown.
// TODO(kpschoedel): Unify with identical value in SideSwipeDetector.
const float kLeavingScreenEdge = 35; const float kLeavingScreenEdge = 35;
// Touch within this distance from a corner can invoke corner passthrough. // Touch within this distance from a corner can invoke corner passthrough.
...@@ -394,7 +393,9 @@ class TouchExplorationController : public ui::EventRewriter, ...@@ -394,7 +393,9 @@ class TouchExplorationController : public ui::EventRewriter,
// edge. If it is within the given inset of two edges, returns an int with // edge. If it is within the given inset of two edges, returns an int with
// both bits that represent the respective edges turned on. Otherwise returns // both bits that represent the respective edges turned on. Otherwise returns
// SCREEN_CENTER. // SCREEN_CENTER.
int FindEdgesWithinInset(gfx::Point point, float inset); int FindEdgesWithinInset(gfx::Point point,
float horiz_inset,
float vert_inset);
// Set the state and modifies any variables related to the state change. // Set the state and modifies any variables related to the state change.
// (e.g. resetting the gesture provider). // (e.g. resetting the gesture provider).
...@@ -497,6 +498,14 @@ class TouchExplorationController : public ui::EventRewriter, ...@@ -497,6 +498,14 @@ class TouchExplorationController : public ui::EventRewriter,
// The maximum touch points seen in the current gesture. // The maximum touch points seen in the current gesture.
size_t max_gesture_touch_points_ = 0; size_t max_gesture_touch_points_ = 0;
// The horizontal and vertical insets for side gesture detection.
const int gesture_start_width_;
const int gesture_start_height_;
// Whether or not to trigger pass through mode when touch events come
// in from the edges.
bool side_gesture_pass_through_;
DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); DISALLOW_COPY_AND_ASSIGN(TouchExplorationController);
}; };
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chromecast/base/cast_features.h"
#include "chromecast/graphics/cast_focus_client_aura.h" #include "chromecast/graphics/cast_focus_client_aura.h"
#include "chromecast/graphics/cast_touch_activity_observer.h" #include "chromecast/graphics/cast_touch_activity_observer.h"
#include "chromecast/graphics/cast_touch_event_gate.h" #include "chromecast/graphics/cast_touch_event_gate.h"
...@@ -280,8 +281,11 @@ void CastWindowManagerAura::Setup() { ...@@ -280,8 +281,11 @@ void CastWindowManagerAura::Setup() {
system_gesture_event_handler_ = system_gesture_event_handler_ =
std::make_unique<CastSystemGestureEventHandler>( std::make_unique<CastSystemGestureEventHandler>(
system_gesture_dispatcher_.get(), root_window); system_gesture_dispatcher_.get(), root_window);
side_swipe_detector_ = std::make_unique<SideSwipeDetector>( // No need for the edge swipe detector when side gestures are pass-through.
system_gesture_dispatcher_.get(), root_window); if (!chromecast::IsFeatureEnabled(kEnableSideGesturePassThrough)) {
side_swipe_detector_ = std::make_unique<SideSwipeDetector>(
system_gesture_dispatcher_.get(), root_window);
}
} }
void CastWindowManagerAura::OnWindowOrderChanged( void CastWindowManagerAura::OnWindowOrderChanged(
......
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