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

Side by Side Diff: remoting/client/gesture_interpreter.cc

Issue 2904703003: [CRD iOS] Add support for three-finger gestures (Closed)
Patch Set: Remove unused import Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « remoting/client/gesture_interpreter.h ('k') | remoting/ios/app/host_view_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gesture_interpreter.h" 5 #include "remoting/client/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/display/renderer_proxy.h" 10 #include "remoting/client/display/renderer_proxy.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 void GestureInterpreter::Pan(float translation_x, float translation_y) { 71 void GestureInterpreter::Pan(float translation_x, float translation_y) {
72 AbortAnimations(); 72 AbortAnimations();
73 PanWithoutAbortAnimations(translation_x, translation_y); 73 PanWithoutAbortAnimations(translation_x, translation_y);
74 } 74 }
75 75
76 void GestureInterpreter::Tap(float x, float y) { 76 void GestureInterpreter::Tap(float x, float y) {
77 AbortAnimations(); 77 AbortAnimations();
78 78
79 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) { 79 InjectMouseClick(x, y, protocol::MouseEvent_MouseButton_BUTTON_LEFT);
80 return;
81 }
82 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
83 StartInputFeedback(cursor_position.x, cursor_position.y,
84 InputStrategy::TAP_FEEDBACK);
85 InjectMouseClick(cursor_position.x, cursor_position.y,
86 protocol::MouseEvent_MouseButton_BUTTON_LEFT);
87 } 80 }
88 81
89 void GestureInterpreter::TwoFingerTap(float x, float y) { 82 void GestureInterpreter::TwoFingerTap(float x, float y) {
90 AbortAnimations(); 83 AbortAnimations();
91 84
92 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) { 85 InjectMouseClick(x, y, protocol::MouseEvent_MouseButton_BUTTON_RIGHT);
93 return; 86 }
94 } 87
95 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition(); 88 void GestureInterpreter::ThreeFingerTap(float x, float y) {
96 InjectMouseClick(cursor_position.x, cursor_position.y, 89 AbortAnimations();
97 protocol::MouseEvent_MouseButton_BUTTON_RIGHT); 90
91 InjectMouseClick(x, y, protocol::MouseEvent_MouseButton_BUTTON_MIDDLE);
98 } 92 }
99 93
100 void GestureInterpreter::Drag(float x, float y, GestureState state) { 94 void GestureInterpreter::Drag(float x, float y, GestureState state) {
101 AbortAnimations(); 95 AbortAnimations();
102 96
103 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) { 97 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) {
104 return; 98 return;
105 } 99 }
106 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition(); 100 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
107 101
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 input_strategy_->MapScreenVectorToDesktop({dx, dy}, viewport_); 180 input_strategy_->MapScreenVectorToDesktop({dx, dy}, viewport_);
187 input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y); 181 input_stub_->SendMouseWheelEvent(desktopDelta.x, desktopDelta.y);
188 } 182 }
189 183
190 void GestureInterpreter::AbortAnimations() { 184 void GestureInterpreter::AbortAnimations() {
191 pan_animation_.Abort(); 185 pan_animation_.Abort();
192 scroll_animation_.Abort(); 186 scroll_animation_.Abort();
193 } 187 }
194 188
195 void GestureInterpreter::InjectMouseClick( 189 void GestureInterpreter::InjectMouseClick(
196 float x, 190 float touch_x,
197 float y, 191 float touch_y,
198 protocol::MouseEvent_MouseButton button) { 192 protocol::MouseEvent_MouseButton button) {
199 input_stub_->SendMouseEvent(x, y, button, true); 193 if (!input_strategy_->TrackTouchInput({touch_x, touch_y}, viewport_)) {
200 input_stub_->SendMouseEvent(x, y, button, false); 194 return;
195 }
196 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
197 StartInputFeedback(cursor_position.x, cursor_position.y,
198 InputStrategy::TAP_FEEDBACK);
199
200 input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y, button,
201 true);
202 input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y, button,
203 false);
201 } 204 }
202 205
203 void GestureInterpreter::SetGestureInProgress(InputStrategy::Gesture gesture, 206 void GestureInterpreter::SetGestureInProgress(InputStrategy::Gesture gesture,
204 bool is_in_progress) { 207 bool is_in_progress) {
205 if (!is_in_progress && gesture_in_progress_ == gesture) { 208 if (!is_in_progress && gesture_in_progress_ == gesture) {
206 gesture_in_progress_ = InputStrategy::NONE; 209 gesture_in_progress_ = InputStrategy::NONE;
207 return; 210 return;
208 } 211 }
209 gesture_in_progress_ = gesture; 212 gesture_in_progress_ = gesture;
210 } 213 }
211 214
212 void GestureInterpreter::StartInputFeedback( 215 void GestureInterpreter::StartInputFeedback(
213 float cursor_x, 216 float cursor_x,
214 float cursor_y, 217 float cursor_y,
215 InputStrategy::InputFeedbackType feedback_type) { 218 InputStrategy::InputFeedbackType feedback_type) {
216 // This radius is on the view's coordinates. Need to be converted to desktop 219 // This radius is on the view's coordinates. Need to be converted to desktop
217 // coordinate. 220 // coordinate.
218 float feedback_radius = input_strategy_->GetFeedbackRadius(feedback_type); 221 float feedback_radius = input_strategy_->GetFeedbackRadius(feedback_type);
219 if (feedback_radius > 0) { 222 if (feedback_radius > 0) {
220 // TODO(yuweih): The renderer takes diameter as parameter. Consider moving 223 // TODO(yuweih): The renderer takes diameter as parameter. Consider moving
221 // the *2 logic inside the renderer. 224 // the *2 logic inside the renderer.
222 float diameter_on_desktop = 225 float diameter_on_desktop =
223 2.f * feedback_radius / viewport_.GetTransformation().GetScale(); 226 2.f * feedback_radius / viewport_.GetTransformation().GetScale();
224 renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop); 227 renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop);
225 } 228 }
226 } 229 }
227 230
228 } // namespace remoting 231 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/gesture_interpreter.h ('k') | remoting/ios/app/host_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698