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

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

Issue 2047903002: [Chromoting] TouchInputHandler now listens to events in DesktopView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 6 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 1cb01ef9d5b207aff58f82e68c3a32fc7a48c6ce..5ed6b968eef63f9fa8e5489ed867a9ec8f044193 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java
@@ -212,52 +212,8 @@ public class TouchInputHandler implements TouchInputHandlerInterface {
mCursorAnimationJob = new CursorAnimationJob(context);
mScrollAnimationJob = new ScrollAnimationJob(context);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- // Give the underlying input strategy a chance to observe the current motion event before
- // passing it to the gesture detectors. This allows the input strategy to react to the
- // event or save the payload for use in recreating the gesture remotely.
- mInputStrategy.onMotionEvent(event);
-
- // Avoid short-circuit logic evaluation - ensure all gesture detectors see all events so
- // that they generate correct notifications.
- boolean handled = mScroller.onTouchEvent(event);
- handled |= mZoomer.onTouchEvent(event);
- handled |= mTapDetector.onTouchEvent(event);
- mSwipePinchDetector.onTouchEvent(event);
-
- switch (event.getActionMasked()) {
- case MotionEvent.ACTION_DOWN:
- mViewer.setAnimationEnabled(false);
- mSuppressCursorMovement = false;
- mSuppressFling = false;
- mSwipeCompleted = false;
- mIsDragging = false;
- break;
-
- case MotionEvent.ACTION_POINTER_DOWN:
- mTotalMotionY = 0;
- break;
-
- default:
- break;
- }
- return handled;
- }
- @Override
- public void onClientSizeChanged(int width, int height) {
- mPanGestureBounds = new Rect(
- mEdgeSlopInPx, mEdgeSlopInPx, width - mEdgeSlopInPx, height - mEdgeSlopInPx);
- mDesktopCanvas.repositionImageWithZoom(true);
- }
-
- @Override
- public void onHostSizeChanged(int width, int height) {
- moveViewport((float) width / 2, (float) height / 2);
- mDesktopCanvas.resizeImageToFitScreen();
+ attachViewEvents(viewer);
}
@Override
@@ -290,6 +246,27 @@ public class TouchInputHandler implements TouchInputHandlerInterface {
});
}
+ private void attachViewEvents(DesktopViewInterface viewer) {
+ viewer.onTouch().add(new Event.ParameterRunnable<TouchEventParameter>() {
+ @Override
+ public void run(TouchEventParameter parameter) {
+ parameter.handled = handleTouchEvent(parameter.event);
+ }
+ });
+ viewer.onClientSizeChanged().add(new Event.ParameterRunnable<SizeChangedEventParameter>() {
+ @Override
+ public void run(SizeChangedEventParameter parameter) {
+ handleClientSizeChanged(parameter.width, parameter.height);
+ }
+ });
+ viewer.onHostSizeChanged().add(new Event.ParameterRunnable<SizeChangedEventParameter>() {
+ @Override
+ public void run(SizeChangedEventParameter parameter) {
+ handleHostSizeChanged(parameter.width, parameter.height);
+ }
+ });
+ }
+
private void handleInputModeChanged(InputModeChangedEventParameter parameter,
Client client) {
final Desktop.InputMode inputMode = parameter.inputMode;
@@ -342,6 +319,49 @@ public class TouchInputHandler implements TouchInputHandlerInterface {
mDesktopCanvas.repositionImage(true);
}
+ private boolean handleTouchEvent(MotionEvent event) {
+ // Give the underlying input strategy a chance to observe the current motion event before
+ // passing it to the gesture detectors. This allows the input strategy to react to the
+ // event or save the payload for use in recreating the gesture remotely.
+ mInputStrategy.onMotionEvent(event);
+
+ // Avoid short-circuit logic evaluation - ensure all gesture detectors see all events so
+ // that they generate correct notifications.
+ boolean handled = mScroller.onTouchEvent(event);
+ handled |= mZoomer.onTouchEvent(event);
+ handled |= mTapDetector.onTouchEvent(event);
+ mSwipePinchDetector.onTouchEvent(event);
+
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ mViewer.setAnimationEnabled(false);
+ mSuppressCursorMovement = false;
+ mSuppressFling = false;
+ mSwipeCompleted = false;
+ mIsDragging = false;
+ break;
+
+ case MotionEvent.ACTION_POINTER_DOWN:
+ mTotalMotionY = 0;
+ break;
+
+ default:
+ break;
+ }
+ return handled;
+ }
+
+ private void handleClientSizeChanged(int width, int height) {
+ mPanGestureBounds = new Rect(
+ mEdgeSlopInPx, mEdgeSlopInPx, width - mEdgeSlopInPx, height - mEdgeSlopInPx);
+ mDesktopCanvas.repositionImageWithZoom(true);
+ }
+
+ private void handleHostSizeChanged(int width, int height) {
+ moveViewport((float) width / 2, (float) height / 2);
+ mDesktopCanvas.resizeImageToFitScreen();
+ }
+
private void setInputStrategy(InputStrategyInterface inputStrategy) {
// Since the rules for flinging differ between input modes, we want to stop running the
// current fling animation when the mode changes to prevent a wonky experience.

Powered by Google App Engine
This is Rietveld 408576698