| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Matrix; | 8 import android.graphics.Matrix; |
| 9 import android.graphics.PointF; | 9 import android.graphics.PointF; |
| 10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 public DesktopView.InputFeedbackType getLongPressFeedbackType() { | 171 public DesktopView.InputFeedbackType getLongPressFeedbackType() { |
| 172 return DesktopView.InputFeedbackType.NONE; | 172 return DesktopView.InputFeedbackType.NONE; |
| 173 } | 173 } |
| 174 | 174 |
| 175 @Override | 175 @Override |
| 176 public boolean isIndirectInputMode() { | 176 public boolean isIndirectInputMode() { |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 public TouchInputHandler(DesktopView viewer, Context context, RenderData ren
derData) { | 181 public TouchInputHandler(DesktopView viewer, Context context) { |
| 182 mViewer = viewer; | 182 mViewer = viewer; |
| 183 mContext = context; | 183 mContext = context; |
| 184 mRenderData = renderData; | 184 mRenderData = new RenderData(); |
| 185 mDesktopCanvas = new DesktopCanvas(mViewer, mRenderData); | 185 mDesktopCanvas = new DesktopCanvas(mViewer, mRenderData); |
| 186 | 186 |
| 187 GestureListener listener = new GestureListener(); | 187 GestureListener listener = new GestureListener(); |
| 188 mScroller = new GestureDetector(context, listener, null, false); | 188 mScroller = new GestureDetector(context, listener, null, false); |
| 189 | 189 |
| 190 // If long-press is enabled, the gesture-detector will not emit any furt
her onScroll | 190 // If long-press is enabled, the gesture-detector will not emit any furt
her onScroll |
| 191 // notifications after the onLongPress notification. Since onScroll is b
eing used for | 191 // notifications after the onLongPress notification. Since onScroll is b
eing used for |
| 192 // moving the cursor, it means that the cursor would become stuck if the
finger were held | 192 // moving the cursor, it means that the cursor would become stuck if the
finger were held |
| 193 // down too long. | 193 // down too long. |
| 194 mScroller.setIsLongpressEnabled(false); | 194 mScroller.setIsLongpressEnabled(false); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 new SimulatedTouchInputStrategy(mRenderData, injecto
r, mContext)); | 286 new SimulatedTouchInputStrategy(mRenderData, injecto
r, mContext)); |
| 287 } | 287 } |
| 288 break; | 288 break; |
| 289 | 289 |
| 290 default: | 290 default: |
| 291 // Unreachable, but required by Google Java style and findbugs. | 291 // Unreachable, but required by Google Java style and findbugs. |
| 292 assert false : "Unreached"; | 292 assert false : "Unreached"; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Ensure the cursor state is updated appropriately. | 295 // Ensure the cursor state is updated appropriately. |
| 296 mViewer.cursorVisibilityChanged(); | 296 mViewer.cursorVisibilityChanged(mRenderData.drawCursor); |
| 297 } | 297 } |
| 298 | 298 |
| 299 private void handleSystemUiVisibilityChanged( | 299 private void handleSystemUiVisibilityChanged( |
| 300 SystemUiVisibilityChangedEventParameter parameter) { | 300 SystemUiVisibilityChangedEventParameter parameter) { |
| 301 if (parameter.softInputMethodVisible) { | 301 if (parameter.softInputMethodVisible) { |
| 302 mDesktopCanvas.setSystemUiOffsetValues(parameter.left, parameter.top
, | 302 mDesktopCanvas.setSystemUiOffsetValues(parameter.left, parameter.top
, |
| 303 mRenderData.screenWidth - parameter.right, | 303 mRenderData.screenWidth - parameter.right, |
| 304 mRenderData.screenHeight - parameter.bottom); | 304 mRenderData.screenHeight - parameter.bottom); |
| 305 } else { | 305 } else { |
| 306 mDesktopCanvas.setSystemUiOffsetValues(0, 0, 0, 0); | 306 mDesktopCanvas.setSystemUiOffsetValues(0, 0, 0, 0); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 335 mTotalMotionY = 0; | 335 mTotalMotionY = 0; |
| 336 break; | 336 break; |
| 337 | 337 |
| 338 default: | 338 default: |
| 339 break; | 339 break; |
| 340 } | 340 } |
| 341 return handled; | 341 return handled; |
| 342 } | 342 } |
| 343 | 343 |
| 344 private void handleClientSizeChanged(int width, int height) { | 344 private void handleClientSizeChanged(int width, int height) { |
| 345 mRenderData.screenWidth = width; |
| 346 mRenderData.screenHeight = height; |
| 347 |
| 345 mPanGestureBounds = new Rect( | 348 mPanGestureBounds = new Rect( |
| 346 mEdgeSlopInPx, mEdgeSlopInPx, width - mEdgeSlopInPx, height - mE
dgeSlopInPx); | 349 mEdgeSlopInPx, mEdgeSlopInPx, width - mEdgeSlopInPx, height - mE
dgeSlopInPx); |
| 347 resizeImageToFitScreen(); | 350 resizeImageToFitScreen(); |
| 348 } | 351 } |
| 349 | 352 |
| 350 private void handleHostSizeChanged(int width, int height) { | 353 private void handleHostSizeChanged(int width, int height) { |
| 354 mRenderData.imageWidth = width; |
| 355 mRenderData.imageHeight = height; |
| 356 |
| 351 resizeImageToFitScreen(); | 357 resizeImageToFitScreen(); |
| 352 } | 358 } |
| 353 | 359 |
| 354 private void resizeImageToFitScreen() { | 360 private void resizeImageToFitScreen() { |
| 355 mDesktopCanvas.resizeImageToFitScreen(); | 361 mDesktopCanvas.resizeImageToFitScreen(); |
| 356 | 362 |
| 357 float screenCenterX = (float) mRenderData.screenWidth / 2; | 363 float screenCenterX = (float) mRenderData.screenWidth / 2; |
| 358 float screenCenterY = (float) mRenderData.screenHeight / 2; | 364 float screenCenterY = (float) mRenderData.screenHeight / 2; |
| 359 | 365 |
| 360 float[] imagePoint = mapScreenPointToImagePoint(screenCenterX, screenCen
terY); | 366 float[] imagePoint = mapScreenPointToImagePoint(screenCenterX, screenCen
terY); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 moveCursor(imagePoint[0], imagePoint[1]); | 408 moveCursor(imagePoint[0], imagePoint[1]); |
| 403 } | 409 } |
| 404 | 410 |
| 405 /** Moves the cursor to the specified position on the remote host. */ | 411 /** Moves the cursor to the specified position on the remote host. */ |
| 406 private void moveCursor(float newX, float newY) { | 412 private void moveCursor(float newX, float newY) { |
| 407 boolean cursorMoved = mRenderData.setCursorPosition(newX, newY); | 413 boolean cursorMoved = mRenderData.setCursorPosition(newX, newY); |
| 408 if (cursorMoved) { | 414 if (cursorMoved) { |
| 409 mInputStrategy.injectCursorMoveEvent((int) newX, (int) newY); | 415 mInputStrategy.injectCursorMoveEvent((int) newX, (int) newY); |
| 410 } | 416 } |
| 411 | 417 |
| 412 mViewer.cursorMoved(); | 418 mViewer.cursorMoved(mRenderData.getCursorPosition()); |
| 413 } | 419 } |
| 414 | 420 |
| 415 /** Processes a (multi-finger) swipe gesture. */ | 421 /** Processes a (multi-finger) swipe gesture. */ |
| 416 private boolean onSwipe() { | 422 private boolean onSwipe() { |
| 417 if (mTotalMotionY > mSwipeThreshold) { | 423 if (mTotalMotionY > mSwipeThreshold) { |
| 418 // Swipe down occurred. | 424 // Swipe down occurred. |
| 419 mViewer.showActionBar(); | 425 mViewer.showActionBar(); |
| 420 } else if (mTotalMotionY < -mSwipeThreshold) { | 426 } else if (mTotalMotionY < -mSwipeThreshold) { |
| 421 // Swipe up occurred. | 427 // Swipe up occurred. |
| 422 mViewer.showKeyboard(); | 428 mViewer.showKeyboard(); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 float[] mappedPoints = mapScreenPointToImagePoint(screenX, screenY); | 642 float[] mappedPoints = mapScreenPointToImagePoint(screenX, screenY); |
| 637 | 643 |
| 638 float imageWidth = (float) mRenderData.imageWidth + EPSILON; | 644 float imageWidth = (float) mRenderData.imageWidth + EPSILON; |
| 639 float imageHeight = (float) mRenderData.imageHeight + EPSILON; | 645 float imageHeight = (float) mRenderData.imageHeight + EPSILON; |
| 640 | 646 |
| 641 return mappedPoints[0] < -EPSILON || mappedPoints[0] > imageWidth | 647 return mappedPoints[0] < -EPSILON || mappedPoints[0] > imageWidth |
| 642 || mappedPoints[1] < -EPSILON || mappedPoints[1] > imageHeig
ht; | 648 || mappedPoints[1] < -EPSILON || mappedPoints[1] > imageHeig
ht; |
| 643 } | 649 } |
| 644 } | 650 } |
| 645 } | 651 } |
| OLD | NEW |