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

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

Issue 2143813002: Preventing touch events from registering when they occur outside the desktop image (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3f518a6f0d8d75bfe3d4fb541530d93a5dde9bed..4cbd35ed60803a8945067e13135d52748f44e497 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
@@ -570,6 +570,9 @@ public class TouchInputHandler {
}
if (!mInputStrategy.isIndirectInputMode()) {
+ if (!mapScreenPointToImage(x, y)) {
+ return false;
+ }
moveCursorToScreenPoint(x, y);
}
@@ -592,6 +595,9 @@ public class TouchInputHandler {
}
if (!mInputStrategy.isIndirectInputMode()) {
+ if (!mapScreenPointToImage(x, y)) {
+ return;
+ }
moveCursorToScreenPoint(x, y);
}
@@ -619,5 +625,22 @@ public class TouchInputHandler {
return InputStub.BUTTON_UNDEFINED;
}
}
+
+ /** Verifies the given point maps to a valid location within the desktop image. */
+ private boolean mapScreenPointToImage(float screenX, float screenY) {
Lambros 2016/07/12 23:19:50 Looks like we have this logic a few times in this
joedow 2016/07/13 00:04:50 Ack. I was thinking this kind of functionality ma
+ float[] mappedPoints = {screenX, screenY};
+ int imageWidth;
+ int imageHeight;
+ Matrix screenToImage = new Matrix();
+ synchronized (mRenderData) {
+ mRenderData.transform.invert(screenToImage);
+ imageWidth = mRenderData.imageWidth;
+ imageHeight = mRenderData.imageHeight;
+ }
+ screenToImage.mapPoints(mappedPoints);
+
+ return (mappedPoints[0] >= 0 && mappedPoints[0] <= imageWidth)
Lambros 2016/07/12 23:19:50 Is it worth adding a little bit of slop margin her
joedow 2016/07/13 00:04:50 I considered that, but this method is only used wh
+ && (mappedPoints[1] >= 0 && mappedPoints[1] <= imageHeight);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698