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

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

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Fix dependency and race condition 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
« no previous file with comments | « remoting/client/ui/gesture_interpreter.h ('k') | remoting/client/ui/input_strategy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/ui/gesture_interpreter.cc
diff --git a/remoting/client/ui/gesture_interpreter.cc b/remoting/client/ui/gesture_interpreter.cc
index 84a6d2ba3dd8f8d0922cf259a701743fe0a8e974..fda5560790bc13bef34a69478b6f4b26089b21c4 100644
--- a/remoting/client/ui/gesture_interpreter.cc
+++ b/remoting/client/ui/gesture_interpreter.cc
@@ -6,7 +6,9 @@
#include "base/bind.h"
#include "base/time/time.h"
+#include "remoting/client/chromoting_session.h"
#include "remoting/client/ui/direct_input_strategy.h"
+#include "remoting/client/ui/renderer_proxy.h"
namespace {
@@ -15,25 +17,29 @@ const float kOneFingerFlingTimeConstant = 325.f;
} // namespace
namespace remoting {
-GestureInterpreter::GestureInterpreter(
- const DesktopViewport::TransformationCallback& on_transformation_changed,
- ChromotingSession* input_stub)
- : input_stub_(input_stub),
+GestureInterpreter::GestureInterpreter(RendererProxy* renderer,
+ ChromotingSession* input_stub)
+ : renderer_(renderer),
+ input_stub_(input_stub),
pan_animation_(kOneFingerFlingTimeConstant,
base::Bind(&GestureInterpreter::PanWithoutAbortAnimations,
base::Unretained(this))) {
- viewport_.RegisterOnTransformationChangedCallback(on_transformation_changed,
- true);
+ viewport_.RegisterOnTransformationChangedCallback(
+ base::Bind(&RendererProxy::SetTransformation,
+ base::Unretained(renderer_)),
+ true);
// TODO(yuweih): This should be configurable.
input_strategy_.reset(new DirectInputStrategy());
+ renderer_->SetCursorVisibility(input_strategy_->IsCursorVisible());
+ SetCursorPositionOnRenderer();
}
GestureInterpreter::~GestureInterpreter() {}
void GestureInterpreter::Pinch(float pivot_x, float pivot_y, float scale) {
AbortAnimations();
- input_strategy_->HandlePinch(pivot_x, pivot_y, scale, &viewport_);
+ input_strategy_->HandlePinch({pivot_x, pivot_y}, scale, &viewport_);
}
void GestureInterpreter::Pan(float translation_x, float translation_y) {
@@ -43,27 +49,34 @@ void GestureInterpreter::Pan(float translation_x, float translation_y) {
void GestureInterpreter::Tap(float x, float y) {
AbortAnimations();
- float cursor_x, cursor_y;
- input_strategy_->FindCursorPositions(x, y, viewport_, &cursor_x, &cursor_y);
- InjectMouseClick(cursor_x, cursor_y,
+
+ ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y);
+ StartInputFeedback(cursor_position.x, cursor_position.y,
+ InputStrategy::TAP_FEEDBACK);
+ InjectMouseClick(cursor_position.x, cursor_position.y,
protocol::MouseEvent_MouseButton_BUTTON_LEFT);
}
void GestureInterpreter::TwoFingerTap(float x, float y) {
AbortAnimations();
- float cursor_x, cursor_y;
- input_strategy_->FindCursorPositions(x, y, viewport_, &cursor_x, &cursor_y);
- InjectMouseClick(cursor_x, cursor_y,
+
+ ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y);
+ InjectMouseClick(cursor_position.x, cursor_position.y,
protocol::MouseEvent_MouseButton_BUTTON_RIGHT);
}
void GestureInterpreter::LongPress(float x, float y, GestureState state) {
AbortAnimations();
- float cursor_x, cursor_y;
- input_strategy_->FindCursorPositions(x, y, viewport_, &cursor_x, &cursor_y);
+
+ ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y);
+
+ if (state == GESTURE_BEGAN) {
+ StartInputFeedback(cursor_position.x, cursor_position.y,
+ InputStrategy::LONG_PRESS_FEEDBACK);
+ }
is_dragging_mode_ = state != GESTURE_ENDED;
- input_stub_->SendMouseEvent(cursor_x, cursor_y,
+ input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y,
protocol::MouseEvent_MouseButton_BUTTON_LEFT,
is_dragging_mode_);
}
@@ -90,8 +103,9 @@ void GestureInterpreter::OnDesktopSizeChanged(int width, int height) {
void GestureInterpreter::PanWithoutAbortAnimations(float translation_x,
float translation_y) {
- input_strategy_->HandlePan(translation_x, translation_y, is_dragging_mode_,
+ input_strategy_->HandlePan({translation_x, translation_y}, is_dragging_mode_,
&viewport_);
+ SetCursorPositionOnRenderer();
}
void GestureInterpreter::AbortAnimations() {
@@ -106,4 +120,33 @@ void GestureInterpreter::InjectMouseClick(
input_stub_->SendMouseEvent(x, y, button, false);
}
+ViewMatrix::Point GestureInterpreter::TrackAndGetPosition(float touch_x,
+ float touch_y) {
+ input_strategy_->TrackTouchInput({touch_x, touch_y}, viewport_);
+ return input_strategy_->GetCursorPosition();
+}
+
+void GestureInterpreter::SetCursorPositionOnRenderer() {
+ if (input_strategy_->IsCursorVisible()) {
+ ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
+ renderer_->SetCursorPosition(cursor_position.x, cursor_position.y);
+ }
+}
+
+void GestureInterpreter::StartInputFeedback(
+ float cursor_x,
+ float cursor_y,
+ InputStrategy::InputFeedbackType feedback_type) {
+ // This radius is on the view's coordinates. Need to be converted to desktop
+ // coordinate.
+ float feedback_radius = input_strategy_->GetFeedbackRadius(feedback_type);
+ if (feedback_radius > 0) {
+ // TODO(yuweih): The renderer takes diameter as parameter. Consider moving
+ // the *2 logic inside the renderer.
+ float diameter_on_desktop =
+ 2.f * feedback_radius / viewport_.GetTransformation().GetScale();
+ renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop);
+ }
+}
+
} // namespace remoting
« no previous file with comments | « remoting/client/ui/gesture_interpreter.h ('k') | remoting/client/ui/input_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698