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

Unified Diff: remoting/client/gesture_interpreter.cc

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Use the ui task poster 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/gesture_interpreter.cc
diff --git a/remoting/client/gesture_interpreter.cc b/remoting/client/gesture_interpreter.cc
index d4389dc9cd41fe163eea13a42de7e184b438c37f..a3540810eaa50c14ddf353b3ccaf21ecb287cb2e 100644
--- a/remoting/client/gesture_interpreter.cc
+++ b/remoting/client/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/direct_input_strategy.h"
+#include "remoting/client/render_stub.h"
namespace {
@@ -15,18 +17,22 @@ 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(RenderStub* render_stub,
+ ChromotingSession* input_stub)
+ : render_stub_(render_stub),
+ input_stub_(input_stub),
pan_animation_(kOneFingerFlingTimeConstant,
base::Bind(&GestureInterpreter::PanWithoutAbortAnimations,
base::Unretained(this))) {
- viewport_.RegisterOnTransformationChangedCallback(on_transformation_changed,
- true);
+ viewport_.RegisterOnTransformationChangedCallback(
+ base::Bind(&RenderStub::SetTransformation,
+ base::Unretained(render_stub_)),
+ true);
// TODO(yuweih): This should be configurable.
input_strategy_.reset(new DirectInputStrategy());
+ render_stub_->SetCursorVisibility(input_strategy_->IsCursorVisible());
+ SetCursorPositionOnRenderStub();
}
GestureInterpreter::~GestureInterpreter() {}
@@ -43,24 +49,32 @@ 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);
+ TrackAndGetPosition(x, y, &cursor_x, &cursor_y);
+ StartInputFeedback(cursor_x, cursor_y, InputStrategy::TAP_FEEDBACK);
InjectMouseClick(cursor_x, cursor_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);
+ TrackAndGetPosition(x, y, &cursor_x, &cursor_y);
InjectMouseClick(cursor_x, cursor_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);
+ TrackAndGetPosition(x, y, &cursor_x, &cursor_y);
+
+ if (state == GESTURE_BEGAN) {
+ StartInputFeedback(cursor_x, cursor_y, InputStrategy::LONG_PRESS_FEEDBACK);
+ }
is_dragging_mode_ = state != GESTURE_ENDED;
input_stub_->SendMouseEvent(cursor_x, cursor_y,
@@ -92,6 +106,7 @@ void GestureInterpreter::PanWithoutAbortAnimations(float translation_x,
float translation_y) {
input_strategy_->HandlePan(translation_x, translation_y, is_dragging_mode_,
&viewport_);
+ SetCursorPositionOnRenderStub();
nicholss 2017/05/12 21:42:40 I don't think "stub" is the correct term. See http
Yuwei 2017/05/13 00:41:52 Done. Renamed to RendererFacade. We did have Clip
}
void GestureInterpreter::AbortAnimations() {
@@ -106,4 +121,36 @@ void GestureInterpreter::InjectMouseClick(
input_stub_->SendMouseEvent(x, y, button, false);
}
+void GestureInterpreter::TrackAndGetPosition(float touch_x,
+ float touch_y,
+ float* cursor_x,
+ float* cursor_y) {
+ input_strategy_->TrackTouchInput(touch_x, touch_y, viewport_);
+ input_strategy_->GetCursorPosition(cursor_x, cursor_y);
+}
+
+void GestureInterpreter::SetCursorPositionOnRenderStub() {
+ if (input_strategy_->IsCursorVisible()) {
+ float cursor_x, cursor_y;
+ input_strategy_->GetCursorPosition(&cursor_x, &cursor_y);
+ render_stub_->SetCursorPosition(cursor_x, cursor_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();
+ render_stub_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop);
+ }
+}
+
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698