| 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..2284149ad45ffecdb7046b776112030333bef2be 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,31 @@ 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::ScrollWithVelocity(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();
|
| - }
|
| + pan_animation_.Tick();
|
| + scroll_animation_.Tick();
|
| }
|
|
|
| void GestureInterpreter::OnSurfaceSizeChanged(int width, int height) {
|
| @@ -108,6 +134,12 @@ void GestureInterpreter::PanWithoutAbortAnimations(float translation_x,
|
| SetCursorPositionOnRenderer();
|
| }
|
|
|
| +void GestureInterpreter::ScrollWithoutAbortAnimations(float dx, float dy) {
|
| + ViewMatrix::Point desktopDelta =
|
| + input_strategy_->MapScreenVectorToDesktop({dx, dy}, viewport_);
|
| + input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y);
|
| +}
|
| +
|
| void GestureInterpreter::AbortAnimations() {
|
| pan_animation_.Abort();
|
| }
|
|
|