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

Unified Diff: chrome/browser/android/vr_shell/vr_controller.cc

Issue 2533493002: VR: Fix click during scrolling (Closed)
Patch Set: Rebase + Address Comments Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_controller.cc
diff --git a/chrome/browser/android/vr_shell/vr_controller.cc b/chrome/browser/android/vr_shell/vr_controller.cc
index a3ddfb61e38a9e3a9bd5062414dd0f2201f7fb1e..bc27cea7ebace232fff6398df0876957172c3689 100644
--- a/chrome/browser/android/vr_shell/vr_controller.cc
+++ b/chrome/browser/android/vr_shell/vr_controller.cc
@@ -206,18 +206,28 @@ std::vector<std::unique_ptr<WebGestureEvent>> VrController::DetectGestures() {
gesture_list.push_back(std::move(gesture));
if (gesture_list.back()->type == WebInputEvent::GestureScrollEnd) {
- std::unique_ptr<WebGestureEvent> fling(new WebGestureEvent());
- fling->timeStampSeconds = gesture_list.back()->timeStampSeconds;
- fling->sourceDevice = blink::WebGestureDeviceTouchpad;
- fling->type = WebInputEvent::GestureFlingStart;
- if (IsHorizontalGesture()) {
- fling->data.flingStart.velocityX =
- overall_velocity_.x * kDisplacementScaleFactor;
+ if (IsButtonDown(gvr::kControllerButtonClick)) {
+ std::unique_ptr<WebGestureEvent> tap_down(new WebGestureEvent());
+ tap_down->type = WebInputEvent::GestureTapDown;
+ tap_down->timeStampSeconds = gesture_list.back()->timeStampSeconds;
+ tap_down->sourceDevice = blink::WebGestureDeviceTouchpad;
+ tap_down->data.tapDown.width = 0;
+ tap_down->data.tapDown.height = 0;
+ gesture_list.push_back(std::move(tap_down));
} else {
- fling->data.flingStart.velocityY =
- overall_velocity_.y * kDisplacementScaleFactor;
+ std::unique_ptr<WebGestureEvent> fling(new WebGestureEvent());
+ fling->timeStampSeconds = gesture_list.back()->timeStampSeconds;
+ fling->sourceDevice = blink::WebGestureDeviceTouchpad;
+ fling->type = WebInputEvent::GestureFlingStart;
+ if (IsHorizontalGesture()) {
+ fling->data.flingStart.velocityX =
+ overall_velocity_.x * kDisplacementScaleFactor;
+ } else {
+ fling->data.flingStart.velocityY =
+ overall_velocity_.y * kDisplacementScaleFactor;
+ }
+ gesture_list.push_back(std::move(fling));
}
- gesture_list.push_back(std::move(fling));
Reset();
}
@@ -268,9 +278,11 @@ void VrController::HandleDetectingState(WebGestureEvent* gesture) {
return;
}
- // Touch position is changed and the touch point moves outside of slop.
+ // Touch position is changed, the touch point moves outside of slop,
+ // and the Controller's button is not down.
if (UpdateCurrentTouchpoint() && touch_info_->is_touching &&
- !InSlop(touch_info_->touch_point.position)) {
+ !InSlop(touch_info_->touch_point.position) &&
+ !IsButtonDown(gvr::kControllerButtonClick)) {
state_ = SCROLLING;
gesture->type = WebInputEvent::GestureScrollBegin;
UpdateGesture(gesture);
@@ -284,7 +296,8 @@ void VrController::HandleDetectingState(WebGestureEvent* gesture) {
void VrController::HandleScrollingState(WebGestureEvent* gesture) {
// Update current touch point.
bool touch_position_changed = UpdateCurrentTouchpoint();
- if (touch_info_->touch_up || !(touch_info_->is_touching)) {
+ if (touch_info_->touch_up || !(touch_info_->is_touching) ||
+ IsButtonDown(gvr::kControllerButtonClick)) {
// Gesture ends.
gesture->type = WebInputEvent::GestureScrollEnd;
UpdateGesture(gesture);
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698