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

Unified Diff: remoting/client/ui/gesture_interpreter.cc

Issue 2882653004: [CRD iOS] Injecting scroll events w/ fling animation (Closed)
Patch Set: Rebase Created 3 years, 7 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: remoting/client/ui/gesture_interpreter.cc
diff --git a/remoting/client/ui/gesture_interpreter.cc b/remoting/client/ui/gesture_interpreter.cc
index fda5560790bc13bef34a69478b6f4b26089b21c4..7cc6b3476bc010bdc3a4219284b2035836ee5e87 100644
--- a/remoting/client/ui/gesture_interpreter.cc
+++ b/remoting/client/ui/gesture_interpreter.cc
@@ -13,6 +13,7 @@
namespace {
const float kOneFingerFlingTimeConstant = 325.f;
+const float kScrollFlingTimeConstant = 120.f;
} // namespace
@@ -23,7 +24,11 @@ GestureInterpreter::GestureInterpreter(RendererProxy* renderer,
input_stub_(input_stub),
pan_animation_(kOneFingerFlingTimeConstant,
base::Bind(&GestureInterpreter::PanWithoutAbortAnimations,
- base::Unretained(this))) {
+ base::Unretained(this))),
+ scroll_animation_(
+ kScrollFlingTimeConstant,
+ base::Bind(&GestureInterpreter::ScrollWithoutAbortAnimations,
+ base::Unretained(this))) {
viewport_.RegisterOnTransformationChangedCallback(
base::Bind(&RendererProxy::SetTransformation,
base::Unretained(renderer_)),
@@ -87,10 +92,34 @@ void GestureInterpreter::OneFingerFling(float velocity_x, float velocity_y) {
pan_animation_.Tick();
}
+void GestureInterpreter::Scroll(float x, float y, float dx, float dy) {
+ AbortAnimations();
+
+ ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y);
+
+ // Inject the cursor position to the host so that scrolling can happen on the
+ // right place.
+ input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y,
+ protocol::MouseEvent_MouseButton_BUTTON_UNDEFINED,
+ false);
+
+ ScrollWithoutAbortAnimations(dx, dy);
+}
+
+void GestureInterpreter::ScrollFling(float velocity_x, float velocity_y) {
+ AbortAnimations();
+
+ scroll_animation_.SetVelocity(velocity_x, velocity_y);
+ scroll_animation_.Tick();
+}
+
void GestureInterpreter::ProcessAnimations() {
if (pan_animation_.IsAnimationInProgress()) {
pan_animation_.Tick();
}
+ if (scroll_animation_.IsAnimationInProgress()) {
nicholss 2017/05/16 18:13:10 Does it hurt to call Tick without checking IsAnima
Yuwei 2017/05/17 05:42:20 Done. TBH nope. Just the negligible overhead of o
+ scroll_animation_.Tick();
+ }
}
void GestureInterpreter::OnSurfaceSizeChanged(int width, int height) {
@@ -108,6 +137,12 @@ void GestureInterpreter::PanWithoutAbortAnimations(float translation_x,
SetCursorPositionOnRenderer();
}
+void GestureInterpreter::ScrollWithoutAbortAnimations(float dx, float dy) {
+ ViewMatrix::Point desktopDelta =
+ input_strategy_->MapScrollVector({dx, dy}, viewport_);
+ input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y);
+}
+
void GestureInterpreter::AbortAnimations() {
pan_animation_.Abort();
}

Powered by Google App Engine
This is Rietveld 408576698