| Index: remoting/client/gesture_interpreter.cc
|
| diff --git a/remoting/client/gesture_interpreter.cc b/remoting/client/gesture_interpreter.cc
|
| index bbdd7d8bcae28729c436cd7450434ad3bd147cc3..85dfd340c1436f01e93eda3963b7c2b85729224c 100644
|
| --- a/remoting/client/gesture_interpreter.cc
|
| +++ b/remoting/client/gesture_interpreter.cc
|
| @@ -3,35 +3,64 @@
|
| // found in the LICENSE file.
|
|
|
| #include "remoting/client/gesture_interpreter.h"
|
| -
|
| #include "base/logging.h"
|
| +#include "remoting/client/direct_input_strategy.h"
|
|
|
| namespace remoting {
|
|
|
| GestureInterpreter::GestureInterpreter(
|
| - const DesktopViewport::TransformationCallback& on_transformation_changed) {
|
| + const DesktopViewport::TransformationCallback& on_transformation_changed,
|
| + ChromotingSession* input_stub)
|
| + : input_stub_(input_stub) {
|
| viewport_.RegisterOnTransformationChangedCallback(on_transformation_changed,
|
| true);
|
| +
|
| + // TODO(yuweih): This should be configurable.
|
| + input_strategy_.reset(new DirectInputStrategy());
|
| }
|
|
|
| GestureInterpreter::~GestureInterpreter() {}
|
|
|
| void GestureInterpreter::Pinch(float pivot_x, float pivot_y, float scale) {
|
| - viewport_.ScaleDesktop(pivot_x, pivot_y, scale);
|
| + input_strategy_->HandlePinch(pivot_x, pivot_y, scale, &viewport_);
|
| }
|
|
|
| void GestureInterpreter::Pan(float translation_x, float translation_y) {
|
| - // TODO(yuweih): Handle trackpad mode where the viewport always focus on the
|
| - // cursor.
|
| - viewport_.MoveDesktop(translation_x, translation_y);
|
| + // TODO(yuweih): Pan deceleration animation.
|
| + input_strategy_->HandlePan(translation_x, translation_y, is_dragging_mode_,
|
| + &viewport_);
|
| }
|
|
|
| void GestureInterpreter::Tap(float x, float y) {
|
| - NOTIMPLEMENTED();
|
| + float cursor_x, cursor_y;
|
| + input_strategy_->FindCursorPositions(x, y, viewport_, &cursor_x, &cursor_y);
|
| + InjectMouseClick(cursor_x, cursor_y,
|
| + protocol::MouseEvent_MouseButton_BUTTON_LEFT);
|
| +}
|
| +
|
| +void GestureInterpreter::TwoFingerTap(float x, float y) {
|
| + float cursor_x, cursor_y;
|
| + input_strategy_->FindCursorPositions(x, y, viewport_, &cursor_x, &cursor_y);
|
| + InjectMouseClick(cursor_x, cursor_y,
|
| + protocol::MouseEvent_MouseButton_BUTTON_RIGHT);
|
| +}
|
| +
|
| +void GestureInterpreter::LongPress(float x, float y, GestureState state) {
|
| + float cursor_x, cursor_y;
|
| + input_strategy_->FindCursorPositions(x, y, viewport_, &cursor_x, &cursor_y);
|
| +
|
| + is_dragging_mode_ = state != GESTURE_ENDED;
|
| + input_stub_->SendMouseEvent(cursor_x, cursor_y,
|
| + protocol::MouseEvent_MouseButton_BUTTON_LEFT,
|
| + is_dragging_mode_);
|
| }
|
|
|
| -void GestureInterpreter::LongPress(float x, float y) {
|
| - NOTIMPLEMENTED();
|
| +void GestureInterpreter::InjectMouseClick(
|
| + float x,
|
| + float y,
|
| + protocol::MouseEvent_MouseButton button) {
|
| + input_stub_->SendMouseEvent(x, y, button, true);
|
| + input_stub_->SendMouseEvent(x, y, button, false);
|
| }
|
|
|
| void GestureInterpreter::OnSurfaceSizeChanged(int width, int height) {
|
|
|