Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/client/ui/gesture_interpreter.h" | 5 #include "remoting/client/ui/gesture_interpreter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "remoting/client/chromoting_session.h" | 9 #include "remoting/client/chromoting_session.h" |
| 10 #include "remoting/client/ui/direct_input_strategy.h" | 10 #include "remoting/client/ui/direct_input_strategy.h" |
| 11 #include "remoting/client/ui/renderer_proxy.h" | 11 #include "remoting/client/ui/renderer_proxy.h" |
| 12 #include "remoting/client/ui/trackpad_input_strategy.h" | 12 #include "remoting/client/ui/trackpad_input_strategy.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const float kOneFingerFlingTimeConstant = 325.f; | 16 const float kOneFingerFlingTimeConstant = 325.f; |
| 17 const float kScrollFlingTimeConstant = 120.f; | 17 const float kScrollFlingTimeConstant = 250.f; |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace remoting { | 21 namespace remoting { |
| 22 GestureInterpreter::GestureInterpreter(RendererProxy* renderer, | 22 GestureInterpreter::GestureInterpreter(RendererProxy* renderer, |
| 23 ChromotingSession* input_stub) | 23 ChromotingSession* input_stub) |
| 24 : renderer_(renderer), | 24 : renderer_(renderer), |
| 25 input_stub_(input_stub), | 25 input_stub_(input_stub), |
| 26 pan_animation_(kOneFingerFlingTimeConstant, | 26 pan_animation_(kOneFingerFlingTimeConstant, |
| 27 base::Bind(&GestureInterpreter::PanWithoutAbortAnimations, | 27 base::Bind(&GestureInterpreter::PanWithoutAbortAnimations, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 void GestureInterpreter::ScrollWithVelocity(float velocity_x, | 129 void GestureInterpreter::ScrollWithVelocity(float velocity_x, |
| 130 float velocity_y) { | 130 float velocity_y) { |
| 131 AbortAnimations(); | 131 AbortAnimations(); |
| 132 | 132 |
| 133 scroll_animation_.SetVelocity(velocity_x, velocity_y); | 133 scroll_animation_.SetVelocity(velocity_x, velocity_y); |
| 134 scroll_animation_.Tick(); | 134 scroll_animation_.Tick(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void GestureInterpreter::ProcessAnimations() { | 137 void GestureInterpreter::ProcessAnimations() { |
| 138 pan_animation_.Tick(); | 138 pan_animation_.Tick(); |
| 139 | |
| 140 // TODO(yuweih): It's probably not right to handle host side animation in | |
| 141 // renderer's callback. | |
| 139 scroll_animation_.Tick(); | 142 scroll_animation_.Tick(); |
|
nicholss
2017/05/22 20:17:00
It is not really animation, more like virtual scro
Yuwei
2017/05/22 21:18:25
Done.
| |
| 140 } | 143 } |
| 141 | 144 |
| 142 void GestureInterpreter::OnSurfaceSizeChanged(int width, int height) { | 145 void GestureInterpreter::OnSurfaceSizeChanged(int width, int height) { |
| 143 viewport_.SetSurfaceSize(width, height); | 146 viewport_.SetSurfaceSize(width, height); |
| 144 } | 147 } |
| 145 | 148 |
| 146 void GestureInterpreter::OnDesktopSizeChanged(int width, int height) { | 149 void GestureInterpreter::OnDesktopSizeChanged(int width, int height) { |
| 147 viewport_.SetDesktopSize(width, height); | 150 viewport_.SetDesktopSize(width, height); |
| 148 } | 151 } |
| 149 | 152 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 167 } | 170 } |
| 168 | 171 |
| 169 void GestureInterpreter::ScrollWithoutAbortAnimations(float dx, float dy) { | 172 void GestureInterpreter::ScrollWithoutAbortAnimations(float dx, float dy) { |
| 170 ViewMatrix::Point desktopDelta = | 173 ViewMatrix::Point desktopDelta = |
| 171 input_strategy_->MapScreenVectorToDesktop({dx, dy}, viewport_); | 174 input_strategy_->MapScreenVectorToDesktop({dx, dy}, viewport_); |
| 172 input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y); | 175 input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y); |
| 173 } | 176 } |
| 174 | 177 |
| 175 void GestureInterpreter::AbortAnimations() { | 178 void GestureInterpreter::AbortAnimations() { |
| 176 pan_animation_.Abort(); | 179 pan_animation_.Abort(); |
| 180 scroll_animation_.Abort(); | |
| 177 } | 181 } |
| 178 | 182 |
| 179 void GestureInterpreter::InjectMouseClick( | 183 void GestureInterpreter::InjectMouseClick( |
| 180 float x, | 184 float x, |
| 181 float y, | 185 float y, |
| 182 protocol::MouseEvent_MouseButton button) { | 186 protocol::MouseEvent_MouseButton button) { |
| 183 input_stub_->SendMouseEvent(x, y, button, true); | 187 input_stub_->SendMouseEvent(x, y, button, true); |
| 184 input_stub_->SendMouseEvent(x, y, button, false); | 188 input_stub_->SendMouseEvent(x, y, button, false); |
| 185 } | 189 } |
| 186 | 190 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 209 if (feedback_radius > 0) { | 213 if (feedback_radius > 0) { |
| 210 // TODO(yuweih): The renderer takes diameter as parameter. Consider moving | 214 // TODO(yuweih): The renderer takes diameter as parameter. Consider moving |
| 211 // the *2 logic inside the renderer. | 215 // the *2 logic inside the renderer. |
| 212 float diameter_on_desktop = | 216 float diameter_on_desktop = |
| 213 2.f * feedback_radius / viewport_.GetTransformation().GetScale(); | 217 2.f * feedback_radius / viewport_.GetTransformation().GetScale(); |
| 214 renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop); | 218 renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop); |
| 215 } | 219 } |
| 216 } | 220 } |
| 217 | 221 |
| 218 } // namespace remoting | 222 } // namespace remoting |
| OLD | NEW |