summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 20:21:54 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-30 20:21:54 +0000
commit9416701585000dd06d1945b165df511238e92877 (patch)
tree874220623908278aa48334225df4a90a24e21cb8 /remoting
parent9eec53fe1841f7ae4d5684074fc3118ef66bb943 (diff)
downloadchromium_src-9416701585000dd06d1945b165df511238e92877.zip
chromium_src-9416701585000dd06d1945b165df511238e92877.tar.gz
chromium_src-9416701585000dd06d1945b165df511238e92877.tar.bz2
[Android Chromoting] Center the desktop if it is smaller than the screen.
If the desktop is smaller than the screen in any direction (left/right or top/bottom), center the desktop in that direction. This eliminates wobble as you move the cursor around whilst zoomed out. Review URL: https://codereview.chromium.org/50373005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231906 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java b/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java
index 809be8b..e7500d8 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TrackingInputHandler.java
@@ -119,7 +119,10 @@ public class TrackingInputHandler implements TouchInputHandler {
float xAdjust = 0;
float yAdjust = 0;
- if (leftDelta > 0 && rightDelta > 0) {
+ if (rectScreen[2] - rectScreen[0] < mRenderData.screenWidth) {
+ // Image is narrower than the screen, so center it.
+ xAdjust = -(rightDelta + leftDelta) / 2;
+ } else 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) {
@@ -128,7 +131,9 @@ public class TrackingInputHandler implements TouchInputHandler {
}
// Apply similar logic for yAdjust.
- if (topDelta > 0 && bottomDelta > 0) {
+ if (rectScreen[3] - rectScreen[1] < mRenderData.screenHeight) {
+ yAdjust = -(bottomDelta + topDelta) / 2;
+ } else if (topDelta > 0 && bottomDelta > 0) {
yAdjust = -Math.min(topDelta, bottomDelta);
} else if (topDelta < 0 && bottomDelta < 0) {
yAdjust = Math.min(-topDelta, -bottomDelta);