| 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.Point; | 9 import android.graphics.Point; |
| 10 import android.graphics.PointF; | 10 import android.graphics.PointF; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 } | 390 } |
| 391 // Determine the center point from which to apply the delta. | 391 // Determine the center point from which to apply the delta. |
| 392 // For indirect input modes (i.e. trackpad), the view generally follows
the cursor. | 392 // For indirect input modes (i.e. trackpad), the view generally follows
the cursor. |
| 393 // For direct input modes (i.e. touch) the should track the user's motio
n. | 393 // For direct input modes (i.e. touch) the should track the user's motio
n. |
| 394 // If the user is dragging, then the viewport should always follow the u
ser's finger. | 394 // If the user is dragging, then the viewport should always follow the u
ser's finger. |
| 395 PointF newPos = mDesktopCanvas.moveViewportCenter(!followCursor, deltaX,
deltaY); | 395 PointF newPos = mDesktopCanvas.moveViewportCenter(!followCursor, deltaX,
deltaY); |
| 396 | 396 |
| 397 // If we are in an indirect mode, then we want to keep the cursor center
ed, if possible, as | 397 // If we are in an indirect mode, then we want to keep the cursor center
ed, if possible, as |
| 398 // the viewport moves. | 398 // the viewport moves. |
| 399 if (mInputStrategy.isIndirectInputMode()) { | 399 if (mInputStrategy.isIndirectInputMode()) { |
| 400 moveCursor((int) newPos.x, (int) newPos.y); | 400 moveCursor((int) newPos.x, (int) newPos.y, true); |
| 401 } | 401 } |
| 402 | 402 |
| 403 mDesktopCanvas.repositionImage(true); | 403 mDesktopCanvas.repositionImage(true); |
| 404 } | 404 } |
| 405 | 405 |
| 406 /** Moves the cursor to the specified position on the screen. */ | 406 /** Moves the cursor to the specified position on the screen. */ |
| 407 private void moveCursorToScreenPoint(float screenX, float screenY) { | 407 private void moveCursorToScreenPoint(float screenX, float screenY) { |
| 408 float[] imagePoint = mapScreenPointToImagePoint(screenX, screenY); | 408 float[] imagePoint = mapScreenPointToImagePoint(screenX, screenY); |
| 409 moveCursor((int) imagePoint[0], (int) imagePoint[1]); | 409 moveCursor((int) imagePoint[0], (int) imagePoint[1], false); |
| 410 } | 410 } |
| 411 | 411 |
| 412 /** Moves the cursor to the specified position on the remote host. */ | 412 /** Moves the cursor to the specified position on the remote host. */ |
| 413 private void moveCursor(int newX, int newY) { | 413 private void moveCursor(int newX, int newY, boolean followedByViewportMove)
{ |
| 414 synchronized (mRenderData) { | 414 synchronized (mRenderData) { |
| 415 boolean cursorMoved = mRenderData.setCursorPosition(newX, newY); | 415 boolean cursorMoved = mRenderData.setCursorPosition(newX, newY); |
| 416 if (cursorMoved) { | 416 if (cursorMoved) { |
| 417 mInputStrategy.injectCursorMoveEvent(newX, newY); | 417 mInputStrategy.injectCursorMoveEvent(newX, newY); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 mViewer.cursorMoved(); | 420 mViewer.cursorMoved(followedByViewportMove); |
| 421 } | 421 } |
| 422 | 422 |
| 423 /** Processes a (multi-finger) swipe gesture. */ | 423 /** Processes a (multi-finger) swipe gesture. */ |
| 424 private boolean onSwipe() { | 424 private boolean onSwipe() { |
| 425 if (mTotalMotionY > mSwipeThreshold) { | 425 if (mTotalMotionY > mSwipeThreshold) { |
| 426 // Swipe down occurred. | 426 // Swipe down occurred. |
| 427 mViewer.showActionBar(); | 427 mViewer.showActionBar(); |
| 428 } else if (mTotalMotionY < -mSwipeThreshold) { | 428 } else if (mTotalMotionY < -mSwipeThreshold) { |
| 429 // Swipe up occurred. | 429 // Swipe up occurred. |
| 430 mViewer.showKeyboard(); | 430 mViewer.showKeyboard(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 synchronized (mRenderData) { | 652 synchronized (mRenderData) { |
| 653 imageWidth = (float) mRenderData.imageWidth + EPSILON; | 653 imageWidth = (float) mRenderData.imageWidth + EPSILON; |
| 654 imageHeight = (float) mRenderData.imageHeight + EPSILON; | 654 imageHeight = (float) mRenderData.imageHeight + EPSILON; |
| 655 } | 655 } |
| 656 | 656 |
| 657 return mappedPoints[0] < -EPSILON || mappedPoints[0] > imageWidth | 657 return mappedPoints[0] < -EPSILON || mappedPoints[0] > imageWidth |
| 658 || mappedPoints[1] < -EPSILON || mappedPoints[1] > imageHeig
ht; | 658 || mappedPoints[1] < -EPSILON || mappedPoints[1] > imageHeig
ht; |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 } | 661 } |
| OLD | NEW |