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

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

Issue 2255663002: [Remoting Android] Use floating point coords for rendering the cursor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge ToT Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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;
10 import android.graphics.PointF; 9 import android.graphics.PointF;
11 import android.graphics.Rect; 10 import android.graphics.Rect;
12 import android.view.GestureDetector; 11 import android.view.GestureDetector;
13 import android.view.MotionEvent; 12 import android.view.MotionEvent;
14 import android.view.ScaleGestureDetector; 13 import android.view.ScaleGestureDetector;
15 import android.view.ViewConfiguration; 14 import android.view.ViewConfiguration;
16 15
17 /** 16 /**
18 * This class is responsible for handling Touch input from the user. Touch even ts which manipulate 17 * This class is responsible for handling Touch input from the user. Touch even ts which manipulate
19 * the local canvas are handled in this class and any input which should be sent to the remote host 18 * the local canvas are handled in this class and any input which should be sent to the remote host
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 389 }
391 // Determine the center point from which to apply the delta. 390 // Determine the center point from which to apply the delta.
392 // For indirect input modes (i.e. trackpad), the view generally follows the cursor. 391 // 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. 392 // 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. 393 // If the user is dragging, then the viewport should always follow the u ser's finger.
395 PointF newPos = mDesktopCanvas.moveViewportCenter(!followCursor, deltaX, deltaY); 394 PointF newPos = mDesktopCanvas.moveViewportCenter(!followCursor, deltaX, deltaY);
396 395
397 // If we are in an indirect mode, then we want to keep the cursor center ed, if possible, as 396 // If we are in an indirect mode, then we want to keep the cursor center ed, if possible, as
398 // the viewport moves. 397 // the viewport moves.
399 if (mInputStrategy.isIndirectInputMode()) { 398 if (mInputStrategy.isIndirectInputMode()) {
400 moveCursor((int) newPos.x, (int) newPos.y); 399 moveCursor(newPos.x, newPos.y);
401 } 400 }
402 401
403 mDesktopCanvas.repositionImage(true); 402 mDesktopCanvas.repositionImage(true);
404 } 403 }
405 404
406 /** Moves the cursor to the specified position on the screen. */ 405 /** Moves the cursor to the specified position on the screen. */
407 private void moveCursorToScreenPoint(float screenX, float screenY) { 406 private void moveCursorToScreenPoint(float screenX, float screenY) {
408 float[] imagePoint = mapScreenPointToImagePoint(screenX, screenY); 407 float[] imagePoint = mapScreenPointToImagePoint(screenX, screenY);
409 moveCursor((int) imagePoint[0], (int) imagePoint[1]); 408 moveCursor(imagePoint[0], imagePoint[1]);
410 } 409 }
411 410
412 /** Moves the cursor to the specified position on the remote host. */ 411 /** Moves the cursor to the specified position on the remote host. */
413 private void moveCursor(int newX, int newY) { 412 private void moveCursor(float newX, float newY) {
414 synchronized (mRenderData) { 413 synchronized (mRenderData) {
415 boolean cursorMoved = mRenderData.setCursorPosition(newX, newY); 414 boolean cursorMoved = mRenderData.setCursorPosition(newX, newY);
416 if (cursorMoved) { 415 if (cursorMoved) {
417 mInputStrategy.injectCursorMoveEvent(newX, newY); 416 mInputStrategy.injectCursorMoveEvent((int) newX, (int) newY);
418 } 417 }
419 } 418 }
420 mViewer.cursorMoved(); 419 mViewer.cursorMoved();
421 } 420 }
422 421
423 /** Processes a (multi-finger) swipe gesture. */ 422 /** Processes a (multi-finger) swipe gesture. */
424 private boolean onSwipe() { 423 private boolean onSwipe() {
425 if (mTotalMotionY > mSwipeThreshold) { 424 if (mTotalMotionY > mSwipeThreshold) {
426 // Swipe down occurred. 425 // Swipe down occurred.
427 mViewer.showActionBar(); 426 mViewer.showActionBar();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 587 }
589 588
590 if (!mInputStrategy.isIndirectInputMode()) { 589 if (!mInputStrategy.isIndirectInputMode()) {
591 if (screenPointLiesOutsideImageBoundary(x, y)) { 590 if (screenPointLiesOutsideImageBoundary(x, y)) {
592 return false; 591 return false;
593 } 592 }
594 moveCursorToScreenPoint(x, y); 593 moveCursorToScreenPoint(x, y);
595 } 594 }
596 595
597 if (mInputStrategy.onTap(button)) { 596 if (mInputStrategy.onTap(button)) {
598 Point pos; 597 PointF pos;
599 synchronized (mRenderData) { 598 synchronized (mRenderData) {
600 pos = mRenderData.getCursorPosition(); 599 pos = mRenderData.getCursorPosition();
601 } 600 }
602 mViewer.showInputFeedback(mInputStrategy.getShortPressFeedbackTy pe(), pos); 601 mViewer.showInputFeedback(mInputStrategy.getShortPressFeedbackTy pe(), pos);
603 } 602 }
604 return true; 603 return true;
605 } 604 }
606 605
607 /** Called when a long-press is triggered for one or more fingers. */ 606 /** Called when a long-press is triggered for one or more fingers. */
608 @Override 607 @Override
609 public void onLongPress(int pointerCount, float x, float y) { 608 public void onLongPress(int pointerCount, float x, float y) {
610 int button = mouseButtonFromPointerCount(pointerCount); 609 int button = mouseButtonFromPointerCount(pointerCount);
611 if (button == InputStub.BUTTON_UNDEFINED) { 610 if (button == InputStub.BUTTON_UNDEFINED) {
612 return; 611 return;
613 } 612 }
614 613
615 if (!mInputStrategy.isIndirectInputMode()) { 614 if (!mInputStrategy.isIndirectInputMode()) {
616 if (screenPointLiesOutsideImageBoundary(x, y)) { 615 if (screenPointLiesOutsideImageBoundary(x, y)) {
617 return; 616 return;
618 } 617 }
619 moveCursorToScreenPoint(x, y); 618 moveCursorToScreenPoint(x, y);
620 } 619 }
621 620
622 if (mInputStrategy.onPressAndHold(button)) { 621 if (mInputStrategy.onPressAndHold(button)) {
623 Point pos; 622 PointF pos;
624 synchronized (mRenderData) { 623 synchronized (mRenderData) {
625 pos = mRenderData.getCursorPosition(); 624 pos = mRenderData.getCursorPosition();
626 } 625 }
627 mViewer.showInputFeedback(mInputStrategy.getLongPressFeedbackTyp e(), pos); 626 mViewer.showInputFeedback(mInputStrategy.getLongPressFeedbackTyp e(), pos);
628 mSuppressFling = true; 627 mSuppressFling = true;
629 mIsDragging = true; 628 mIsDragging = true;
630 } 629 }
631 } 630 }
632 631
633 /** Maps the number of fingers in a tap or long-press gesture to a mouse -button. */ 632 /** Maps the number of fingers in a tap or long-press gesture to a mouse -button. */
(...skipping 18 matching lines...) Expand all
652 synchronized (mRenderData) { 651 synchronized (mRenderData) {
653 imageWidth = (float) mRenderData.imageWidth + EPSILON; 652 imageWidth = (float) mRenderData.imageWidth + EPSILON;
654 imageHeight = (float) mRenderData.imageHeight + EPSILON; 653 imageHeight = (float) mRenderData.imageHeight + EPSILON;
655 } 654 }
656 655
657 return mappedPoints[0] < -EPSILON || mappedPoints[0] > imageWidth 656 return mappedPoints[0] < -EPSILON || mappedPoints[0] > imageWidth
658 || mappedPoints[1] < -EPSILON || mappedPoints[1] > imageHeig ht; 657 || mappedPoints[1] < -EPSILON || mappedPoints[1] > imageHeig ht;
659 } 658 }
660 } 659 }
661 } 660 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698