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

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

Issue 2378303002: Adjust viewport center when in trackpad input mode. (Closed)
Patch Set: Merging with ToT Created 4 years, 2 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
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java
index 778c395267e875f75548e8ff8aa6acc33aa484e0..52aa6ca7121d5d11c7efc9b82c3a27f2285d8ccd 100644
--- a/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java
+++ b/remoting/android/java/src/org/chromium/chromoting/DesktopCanvas.java
@@ -58,6 +58,18 @@ public class DesktopCanvas {
*/
private RectF mVisibleImagePadding = new RectF();
+ /**
+ * Tracks whether to adjust the viewport to account for System UI. If false, the viewport
+ * center is the center of the screen. If true, then System UI offsets will be used to
+ * adjust the position of the viewport to ensure the cursor is visible.
+ */
+ private boolean mAdjustViewportForSystemUi = false;
+
+ /**
+ * Represents the amount of space, in pixels, to adjust the cursor center along the y-axis.
+ */
+ private float mCursorOffsetScreenY = 0.0f;
+
public DesktopCanvas(RenderStub renderStub, RenderData renderData) {
mRenderStub = renderStub;
mRenderData = renderData;
@@ -122,13 +134,33 @@ public class DesktopCanvas {
*/
public void setSystemUiOffsetValues(int left, int top, int right, int bottom) {
mSystemUiScreenSize.set(left, top, right, bottom);
+
+ // Adjust the cursor position to ensure it visible when large System UI (defined as 1/3 or
Lambros 2016/10/05 01:35:54 s/it/it is/
joedow 2016/10/05 16:12:26 Done.
+ // more of the total screen size) is displayed. This is typically the Soft Keyboard.
+ // Without this change, it is difficult for users to enter text into edit controls which are
+ // located bottom of the screen and may not be able to view their cursor at all.
+ if (mAdjustViewportForSystemUi && bottom > (mRenderData.screenHeight / 3)) {
+ // Center the cursor within the viewable area (not obscurred by System UI).
Lambros 2016/10/05 01:35:54 obscured
joedow 2016/10/05 16:12:26 Done.
+ mCursorOffsetScreenY = (((float) mRenderData.screenHeight - bottom) / 2.0f);
+ } else {
+ mCursorOffsetScreenY = 0.0f;
+ }
+
+ if (mAdjustViewportForSystemUi) {
+ setCursorPosition(mCursorPosition.x, mCursorPosition.y);
Lambros 2016/10/05 01:35:54 This feels suspect. Why do you need this call only
joedow 2016/10/05 16:12:26 It only affects the case where the cursor offset c
+ }
}
/** Called to indicate that no System UI is visible. */
public void clearSystemUiOffsets() {
+ mCursorOffsetScreenY = 0.0f;
mSystemUiScreenSize.setEmpty();
}
+ public void adjustViewportForSystemUi(boolean adjustViewportForSystemUi) {
+ mAdjustViewportForSystemUi = adjustViewportForSystemUi;
+ }
+
/** Resizes the image by zooming it such that the image is displayed without borders. */
public void resizeImageToFitScreen() {
// Protect against being called before the image has been initialized.
@@ -220,7 +252,8 @@ public class DesktopCanvas {
mRenderData.transform.mapPoints(viewportPosition);
float viewportTransX = ((float) mRenderData.screenWidth / 2) - viewportPosition[0];
- float viewportTransY = ((float) mRenderData.screenHeight / 2) - viewportPosition[1];
+ float viewportTransY =
+ ((float) mRenderData.screenHeight / 2) - viewportPosition[1] - mCursorOffsetScreenY;
// Translate the image so the viewport center is displayed in the middle of the screen.
Lambros 2016/10/05 01:35:54 I guess "middle of the screen" is no longer accura
joedow 2016/10/05 16:12:26 That's true, this comment should be updated.
mRenderData.transform.postTranslate(viewportTransX, viewportTransY);
@@ -263,9 +296,10 @@ public class DesktopCanvas {
// the desktop image from 'snapping' back to pre-System UI state.
RectF systemUiOverlap = getSystemUiOverlap();
float[] padding = {Math.max(mVisibleImagePadding.left, systemUiOverlap.left),
- Math.max(mVisibleImagePadding.top, systemUiOverlap.top),
+ Math.max(mVisibleImagePadding.top + mCursorOffsetScreenY, systemUiOverlap.top),
Math.max(mVisibleImagePadding.right, systemUiOverlap.right),
- Math.max(mVisibleImagePadding.bottom, systemUiOverlap.bottom)};
+ Math.max(mVisibleImagePadding.bottom - mCursorOffsetScreenY,
+ systemUiOverlap.bottom)};
Matrix screenToImage = new Matrix();
mRenderData.transform.invert(screenToImage);
screenToImage.mapVectors(padding);
@@ -325,9 +359,10 @@ public class DesktopCanvas {
// Note: Ignore negative padding (clamp to 0) since that means no overlap exists.
PointF letterboxPadding = getLetterboxPadding();
return new RectF(Math.max(mSystemUiScreenSize.left - letterboxPadding.x, 0.0f),
- Math.max(mSystemUiScreenSize.top - letterboxPadding.y, 0.0f),
+ Math.max(mSystemUiScreenSize.top - letterboxPadding.y + mCursorOffsetScreenY, 0.0f),
Math.max(mSystemUiScreenSize.right - letterboxPadding.x, 0.0f),
- Math.max(mSystemUiScreenSize.bottom - letterboxPadding.y, 0.0f));
+ Math.max(mSystemUiScreenSize.bottom - letterboxPadding.y - mCursorOffsetScreenY,
+ 0.0f));
}
/**
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698