summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-28 19:30:16 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-28 19:30:16 +0000
commit5c3f4f9f8e4035c61b70221e7e2d97494b5e4b73 (patch)
treec294a13254d4aab3f53478153d9301959c2ef42e /remoting
parent7bc74e5f32dad6db6ffefb9f9d4341b5d322b3f4 (diff)
downloadchromium_src-5c3f4f9f8e4035c61b70221e7e2d97494b5e4b73.zip
chromium_src-5c3f4f9f8e4035c61b70221e7e2d97494b5e4b73.tar.gz
chromium_src-5c3f4f9f8e4035c61b70221e7e2d97494b5e4b73.tar.bz2
Android Chromoting: show more of the desktop if cursor is near an edge.
If the cursor is near the edge of the remote desktop, reposition the image so that more of it is visible. Still TODO: Constrain the zoom level. Review URL: https://codereview.chromium.org/46393002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231377 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java b/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java
index 30b66cc..2eaa14a 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java
@@ -97,6 +97,39 @@ public class TrackingInputHandler implements TouchInputHandler {
mRenderData.transform.postTranslate(
(float)mRenderData.screenWidth / 2 - cursorScreen[0],
(float)mRenderData.screenHeight / 2 - cursorScreen[1]);
+
+ // Now the cursor is displayed in the middle of the screen, see if the image can be
+ // panned so that more of it is visible. The primary goal is to show as much of the
+ // image as possible. The secondary goal is to keep the cursor in the middle.
+
+ // Get the coordinates of the desktop rectangle (top-left/bottom-right corners) in
+ // screen coordinates. Order is: left, top, right, bottom.
+ float[] rectScreen = {0, 0, mRenderData.imageWidth, mRenderData.imageHeight};
+ mRenderData.transform.mapPoints(rectScreen);
+
+ float leftDelta = rectScreen[0];
+ float rightDelta = rectScreen[2] - mRenderData.screenWidth;
+ float topDelta = rectScreen[1];
+ float bottomDelta = rectScreen[3] - mRenderData.screenHeight;
+ float xAdjust = 0;
+ float yAdjust = 0;
+
+ if (leftDelta > 0 && rightDelta > 0) {
+ // Panning the image left will show more of it.
+ xAdjust = -Math.min(leftDelta, rightDelta);
+ } else if (leftDelta < 0 && rightDelta < 0) {
+ // Pan the image right.
+ xAdjust = Math.min(-leftDelta, -rightDelta);
+ }
+
+ // Apply similar logic for yAdjust.
+ if (topDelta > 0 && bottomDelta > 0) {
+ yAdjust = -Math.min(topDelta, bottomDelta);
+ } else if (topDelta < 0 && bottomDelta < 0) {
+ yAdjust = Math.min(-topDelta, -bottomDelta);
+ }
+
+ mRenderData.transform.postTranslate(xAdjust, yAdjust);
}
mViewer.transformationChanged();
}