Commit 5aa63e06 authored by Aldo Culquicondor's avatar Aldo Culquicondor Committed by Commit Bot

Increase touch slop when entering/leaving VR

VR input devices behave like laser pointers, leading to movements with
lower precision as opposed to a mouse or a touchpad, due to natural
shakiness of users. This change increases the slop when on VR browsing,
as a factor of the platform's slop.

Bug: 860321
Change-Id: I47906921ab41e69b7bc4e427ebbd327ae8f7d9bf
Reviewed-on: https://chromium-review.googlesource.com/1134088
Commit-Queue: Aldo Culquicondor <acondor@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574957}
parent a03bae09
...@@ -1887,6 +1887,10 @@ void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) { ...@@ -1887,6 +1887,10 @@ void RenderWidgetHostViewAndroid::SetIsInVR(bool is_in_vr) {
// TODO(crbug.com/851054): support touch selection handles in VR. // TODO(crbug.com/851054): support touch selection handles in VR.
SetTextHandlesHiddenInternal(); SetTextHandlesHiddenInternal();
gesture_provider_.UpdateConfig(ui::GetGestureProviderConfig(
is_in_vr_ ? ui::GestureProviderConfigType::CURRENT_PLATFORM_VR
: ui::GestureProviderConfigType::CURRENT_PLATFORM));
if (is_in_vr_ && controls_initialized_) { if (is_in_vr_ && controls_initialized_) {
// TODO(mthiesse, https://crbug.com/825765): See the TODO in // TODO(mthiesse, https://crbug.com/825765): See the TODO in
// RenderWidgetHostViewAndroid::OnFrameMetadataUpdated. RWHVA isn't // RenderWidgetHostViewAndroid::OnFrameMetadataUpdated. RWHVA isn't
......
...@@ -18,10 +18,16 @@ FilteredGestureProvider::FilteredGestureProvider( ...@@ -18,10 +18,16 @@ FilteredGestureProvider::FilteredGestureProvider(
const GestureProvider::Config& config, const GestureProvider::Config& config,
GestureProviderClient* client) GestureProviderClient* client)
: client_(client), : client_(client),
gesture_provider_(config, this), gesture_provider_(std::make_unique<GestureProvider>(config, this)),
gesture_filter_(this), gesture_filter_(this),
handling_event_(false), handling_event_(false),
any_touch_moved_beyond_slop_region_(false) { any_touch_moved_beyond_slop_region_(false) {}
FilteredGestureProvider::~FilteredGestureProvider() = default;
void FilteredGestureProvider::UpdateConfig(
const GestureProvider::Config& config) {
gesture_provider_ = std::make_unique<ui::GestureProvider>(config, this);
} }
FilteredGestureProvider::TouchHandlingResult FilteredGestureProvider::TouchHandlingResult
...@@ -34,7 +40,7 @@ FilteredGestureProvider::OnTouchEvent(const MotionEvent& event) { ...@@ -34,7 +40,7 @@ FilteredGestureProvider::OnTouchEvent(const MotionEvent& event) {
if (event.GetAction() == MotionEvent::Action::DOWN) if (event.GetAction() == MotionEvent::Action::DOWN)
any_touch_moved_beyond_slop_region_ = false; any_touch_moved_beyond_slop_region_ = false;
if (!gesture_provider_.OnTouchEvent(event)) if (!gesture_provider_->OnTouchEvent(event))
return TouchHandlingResult(); return TouchHandlingResult();
TouchDispositionGestureFilter::PacketResult filter_result = TouchDispositionGestureFilter::PacketResult filter_result =
...@@ -59,25 +65,25 @@ void FilteredGestureProvider::OnTouchEventAck( ...@@ -59,25 +65,25 @@ void FilteredGestureProvider::OnTouchEventAck(
} }
void FilteredGestureProvider::ResetDetection() { void FilteredGestureProvider::ResetDetection() {
gesture_provider_.ResetDetection(); gesture_provider_->ResetDetection();
} }
void FilteredGestureProvider::SetMultiTouchZoomSupportEnabled( void FilteredGestureProvider::SetMultiTouchZoomSupportEnabled(
bool enabled) { bool enabled) {
gesture_provider_.SetMultiTouchZoomSupportEnabled(enabled); gesture_provider_->SetMultiTouchZoomSupportEnabled(enabled);
} }
void FilteredGestureProvider::SetDoubleTapSupportForPlatformEnabled( void FilteredGestureProvider::SetDoubleTapSupportForPlatformEnabled(
bool enabled) { bool enabled) {
gesture_provider_.SetDoubleTapSupportForPlatformEnabled(enabled); gesture_provider_->SetDoubleTapSupportForPlatformEnabled(enabled);
} }
void FilteredGestureProvider::SetDoubleTapSupportForPageEnabled(bool enabled) { void FilteredGestureProvider::SetDoubleTapSupportForPageEnabled(bool enabled) {
gesture_provider_.SetDoubleTapSupportForPageEnabled(enabled); gesture_provider_->SetDoubleTapSupportForPageEnabled(enabled);
} }
const ui::MotionEvent* FilteredGestureProvider::GetCurrentDownEvent() const { const ui::MotionEvent* FilteredGestureProvider::GetCurrentDownEvent() const {
return gesture_provider_.current_down_event(); return gesture_provider_->current_down_event();
} }
void FilteredGestureProvider::OnGestureEvent(const GestureEventData& event) { void FilteredGestureProvider::OnGestureEvent(const GestureEventData& event) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define UI_EVENTS_GESTURE_DETECTION_FILTERED_GESTURE_PROVIDER_H_ #define UI_EVENTS_GESTURE_DETECTION_FILTERED_GESTURE_PROVIDER_H_
#include <stdint.h> #include <stdint.h>
#include <memory>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -25,6 +26,9 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider ...@@ -25,6 +26,9 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider
// and allowed by the |gesture_filter_|. // and allowed by the |gesture_filter_|.
FilteredGestureProvider(const GestureProvider::Config& config, FilteredGestureProvider(const GestureProvider::Config& config,
GestureProviderClient* client); GestureProviderClient* client);
~FilteredGestureProvider() final;
void UpdateConfig(const GestureProvider::Config& config);
struct TouchHandlingResult { struct TouchHandlingResult {
TouchHandlingResult(); TouchHandlingResult();
...@@ -62,7 +66,7 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider ...@@ -62,7 +66,7 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider
GestureProviderClient* const client_; GestureProviderClient* const client_;
ui::GestureProvider gesture_provider_; std::unique_ptr<ui::GestureProvider> gesture_provider_;
ui::TouchDispositionGestureFilter gesture_filter_; ui::TouchDispositionGestureFilter gesture_filter_;
bool handling_event_; bool handling_event_;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
namespace ui { namespace ui {
namespace { namespace {
constexpr float kSlopScaleForVr = 3.0f;
class GenericDesktopGestureConfiguration : public GestureConfiguration { class GenericDesktopGestureConfiguration : public GestureConfiguration {
public: public:
// The default GestureConfiguration parameters are already tailored for a // The default GestureConfiguration parameters are already tailored for a
...@@ -72,6 +74,10 @@ GestureProvider::Config BuildGestureProviderConfig( ...@@ -72,6 +74,10 @@ GestureProvider::Config BuildGestureProviderConfig(
return config; return config;
} }
void TuneGestureProviderConfigForVr(GestureProvider::Config* config) {
config->gesture_detector_config.touch_slop *= kSlopScaleForVr;
}
} // namespace } // namespace
GestureProvider::Config GetGestureProviderConfig( GestureProvider::Config GetGestureProviderConfig(
...@@ -81,6 +87,10 @@ GestureProvider::Config GetGestureProviderConfig( ...@@ -81,6 +87,10 @@ GestureProvider::Config GetGestureProviderConfig(
case GestureProviderConfigType::CURRENT_PLATFORM: case GestureProviderConfigType::CURRENT_PLATFORM:
config = BuildGestureProviderConfig(*GestureConfiguration::GetInstance()); config = BuildGestureProviderConfig(*GestureConfiguration::GetInstance());
break; break;
case GestureProviderConfigType::CURRENT_PLATFORM_VR:
config = BuildGestureProviderConfig(*GestureConfiguration::GetInstance());
TuneGestureProviderConfigForVr(&config);
break;
case GestureProviderConfigType::GENERIC_DESKTOP: case GestureProviderConfigType::GENERIC_DESKTOP:
config = BuildGestureProviderConfig(GenericDesktopGestureConfiguration()); config = BuildGestureProviderConfig(GenericDesktopGestureConfiguration());
break; break;
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
namespace ui { namespace ui {
enum class GestureProviderConfigType { enum class GestureProviderConfigType {
CURRENT_PLATFORM, // Parameters tailored for the current platform. CURRENT_PLATFORM, // Parameters tailored for the current platform.
GENERIC_DESKTOP, // Parameters typical for a desktop machine. CURRENT_PLATFORM_VR, // Parameters tailored for the current platform in VR.
GENERIC_MOBILE // Parameters typical for a mobile device (phone/tablet). GENERIC_DESKTOP, // Parameters typical for a desktop machine.
GENERIC_MOBILE // Parameters typical for a mobile device (phone/tablet).
}; };
GESTURE_DETECTION_EXPORT GestureProvider::Config GetGestureProviderConfig( GESTURE_DETECTION_EXPORT GestureProvider::Config GetGestureProviderConfig(
......
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