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

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

Issue 2897143002: [CRD iOS] Ignore touch event when the touch point is out of the canvas in direct input mode (Closed)
Patch Set: 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 unified diff | 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 »
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/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"
(...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 ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y); 79 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) {
80 return;
81 }
82 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
80 StartInputFeedback(cursor_position.x, cursor_position.y, 83 StartInputFeedback(cursor_position.x, cursor_position.y,
81 InputStrategy::TAP_FEEDBACK); 84 InputStrategy::TAP_FEEDBACK);
82 InjectMouseClick(cursor_position.x, cursor_position.y, 85 InjectMouseClick(cursor_position.x, cursor_position.y,
83 protocol::MouseEvent_MouseButton_BUTTON_LEFT); 86 protocol::MouseEvent_MouseButton_BUTTON_LEFT);
84 } 87 }
85 88
86 void GestureInterpreter::TwoFingerTap(float x, float y) { 89 void GestureInterpreter::TwoFingerTap(float x, float y) {
87 AbortAnimations(); 90 AbortAnimations();
88 91
89 ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y); 92 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) {
93 return;
94 }
95 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
90 InjectMouseClick(cursor_position.x, cursor_position.y, 96 InjectMouseClick(cursor_position.x, cursor_position.y,
91 protocol::MouseEvent_MouseButton_BUTTON_RIGHT); 97 protocol::MouseEvent_MouseButton_BUTTON_RIGHT);
92 } 98 }
93 99
94 void GestureInterpreter::Drag(float x, float y, GestureState state) { 100 void GestureInterpreter::Drag(float x, float y, GestureState state) {
95 AbortAnimations(); 101 AbortAnimations();
96 102
97 ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y); 103 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) {
104 return;
105 }
106 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
98 107
99 if (state == GESTURE_BEGAN) { 108 if (state == GESTURE_BEGAN) {
100 StartInputFeedback(cursor_position.x, cursor_position.y, 109 StartInputFeedback(cursor_position.x, cursor_position.y,
101 InputStrategy::DRAG_FEEDBACK); 110 InputStrategy::DRAG_FEEDBACK);
102 } 111 }
103 112
104 bool is_dragging_mode = state != GESTURE_ENDED; 113 bool is_dragging_mode = state != GESTURE_ENDED;
105 SetGestureInProgress(InputStrategy::DRAG, is_dragging_mode); 114 SetGestureInProgress(InputStrategy::DRAG, is_dragging_mode);
106 input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y, 115 input_stub_->SendMouseEvent(cursor_position.x, cursor_position.y,
107 protocol::MouseEvent_MouseButton_BUTTON_LEFT, 116 protocol::MouseEvent_MouseButton_BUTTON_LEFT,
108 is_dragging_mode); 117 is_dragging_mode);
109 } 118 }
110 119
111 void GestureInterpreter::OneFingerFling(float velocity_x, float velocity_y) { 120 void GestureInterpreter::OneFingerFling(float velocity_x, float velocity_y) {
112 AbortAnimations(); 121 AbortAnimations();
113 pan_animation_.SetVelocity(velocity_x, velocity_y); 122 pan_animation_.SetVelocity(velocity_x, velocity_y);
114 pan_animation_.Tick(); 123 pan_animation_.Tick();
115 } 124 }
116 125
117 void GestureInterpreter::Scroll(float x, float y, float dx, float dy) { 126 void GestureInterpreter::Scroll(float x, float y, float dx, float dy) {
118 AbortAnimations(); 127 AbortAnimations();
119 128
120 ViewMatrix::Point cursor_position = TrackAndGetPosition(x, y); 129 if (!input_strategy_->TrackTouchInput({x, y}, viewport_)) {
130 return;
131 }
132 ViewMatrix::Point cursor_position = input_strategy_->GetCursorPosition();
121 133
122 // Inject the cursor position to the host so that scrolling can happen on the 134 // Inject the cursor position to the host so that scrolling can happen on the
123 // right place. 135 // right place.
124 InjectCursorPosition(cursor_position.x, cursor_position.y); 136 InjectCursorPosition(cursor_position.x, cursor_position.y);
125 137
126 ScrollWithoutAbortAnimations(dx, dy); 138 ScrollWithoutAbortAnimations(dx, dy);
127 } 139 }
128 140
129 void GestureInterpreter::ScrollWithVelocity(float velocity_x, 141 void GestureInterpreter::ScrollWithVelocity(float velocity_x,
130 float velocity_y) { 142 float velocity_y) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 202
191 void GestureInterpreter::SetGestureInProgress(InputStrategy::Gesture gesture, 203 void GestureInterpreter::SetGestureInProgress(InputStrategy::Gesture gesture,
192 bool is_in_progress) { 204 bool is_in_progress) {
193 if (!is_in_progress && gesture_in_progress_ == gesture) { 205 if (!is_in_progress && gesture_in_progress_ == gesture) {
194 gesture_in_progress_ = InputStrategy::NONE; 206 gesture_in_progress_ = InputStrategy::NONE;
195 return; 207 return;
196 } 208 }
197 gesture_in_progress_ = gesture; 209 gesture_in_progress_ = gesture;
198 } 210 }
199 211
200 ViewMatrix::Point GestureInterpreter::TrackAndGetPosition(float touch_x,
201 float touch_y) {
202 input_strategy_->TrackTouchInput({touch_x, touch_y}, viewport_);
203 return input_strategy_->GetCursorPosition();
204 }
205
206 void GestureInterpreter::StartInputFeedback( 212 void GestureInterpreter::StartInputFeedback(
207 float cursor_x, 213 float cursor_x,
208 float cursor_y, 214 float cursor_y,
209 InputStrategy::InputFeedbackType feedback_type) { 215 InputStrategy::InputFeedbackType feedback_type) {
210 // This radius is on the view's coordinates. Need to be converted to desktop 216 // This radius is on the view's coordinates. Need to be converted to desktop
211 // coordinate. 217 // coordinate.
212 float feedback_radius = input_strategy_->GetFeedbackRadius(feedback_type); 218 float feedback_radius = input_strategy_->GetFeedbackRadius(feedback_type);
213 if (feedback_radius > 0) { 219 if (feedback_radius > 0) {
214 // TODO(yuweih): The renderer takes diameter as parameter. Consider moving 220 // TODO(yuweih): The renderer takes diameter as parameter. Consider moving
215 // the *2 logic inside the renderer. 221 // the *2 logic inside the renderer.
216 float diameter_on_desktop = 222 float diameter_on_desktop =
217 2.f * feedback_radius / viewport_.GetTransformation().GetScale(); 223 2.f * feedback_radius / viewport_.GetTransformation().GetScale();
218 renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop); 224 renderer_->StartInputFeedback(cursor_x, cursor_y, diameter_on_desktop);
219 } 225 }
220 } 226 }
221 227
222 } // namespace remoting 228 } // namespace remoting
OLDNEW
« 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