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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java

Issue 2372663002: Separating cursor and viewport calculations in the desktop canvas (Closed)
Patch Set: Merging with ToT and doing some pre-review clean-up Created 4 years, 3 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/android/java/src/org/chromium/chromoting/TouchInputHandler.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
index b142d715220252b9af900a65c53fa347b7e5f0ad..3ff7047aee7e5f0ee4c3b81aada8f681f32c945b 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
@@ -327,6 +327,7 @@ public class TouchInputHandler {
switch (inputMode) {
case TRACKPAD:
setInputStrategy(new TrackpadInputStrategy(mRenderData, injector));
+ moveCursorToScreenCenter();
break;
case TOUCH:
@@ -356,8 +357,6 @@ public class TouchInputHandler {
} else {
mDesktopCanvas.clearSystemUiOffsets();
}
-
- mDesktopCanvas.repositionImage(true);
}
private boolean handleTouchEvent(MotionEvent event) {
@@ -411,14 +410,19 @@ public class TouchInputHandler {
private void resizeImageToFitScreen() {
mDesktopCanvas.resizeImageToFitScreen();
+ moveCursorToScreenCenter();
+
+ mDesktopCanvas.repositionImage();
+ }
+
+ private void moveCursorToScreenCenter() {
float screenCenterX = (float) mRenderData.screenWidth / 2;
float screenCenterY = (float) mRenderData.screenHeight / 2;
float[] imagePoint = mapScreenPointToImagePoint(screenCenterX, screenCenterY);
- mDesktopCanvas.setViewportPosition(imagePoint[0], imagePoint[1]);
+ mDesktopCanvas.setViewportCenter(imagePoint[0], imagePoint[1]);
moveCursorToScreenPoint(screenCenterX, screenCenterY);
- mDesktopCanvas.repositionImage(true);
}
private void setInputStrategy(InputStrategyInterface inputStrategy) {
@@ -437,19 +441,19 @@ public class TouchInputHandler {
deltaX = -deltaX;
deltaY = -deltaY;
}
+
// Determine the center point from which to apply the delta.
// For indirect input modes (i.e. trackpad), the view generally follows the cursor.
// For direct input modes (i.e. touch) the should track the user's motion.
// If the user is dragging, then the viewport should always follow the user's finger.
- PointF newPos = mDesktopCanvas.moveViewportCenter(!followCursor, deltaX, deltaY);
-
- // If we are in an indirect mode, then we want to keep the cursor centered, if possible, as
- // the viewport moves.
if (mInputStrategy.isIndirectInputMode()) {
- moveCursor(newPos.x, newPos.y);
+ PointF newCursorPos = mDesktopCanvas.moveViewportWithCursor(deltaX, deltaY);
+ moveCursor(newCursorPos.x, newCursorPos.y);
+ } else {
+ mDesktopCanvas.moveViewportCenter(deltaX, deltaY);
}
- mDesktopCanvas.repositionImage(true);
+ mDesktopCanvas.repositionImage();
}
/** Moves the cursor to the specified position on the screen. */

Powered by Google App Engine
This is Rietveld 408576698