| 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.PointF; | 10 import android.graphics.PointF; |
| 10 import android.graphics.Rect; | 11 import android.graphics.Rect; |
| 11 import android.view.GestureDetector; | 12 import android.view.GestureDetector; |
| 12 import android.view.MotionEvent; | 13 import android.view.MotionEvent; |
| 13 import android.view.ScaleGestureDetector; | 14 import android.view.ScaleGestureDetector; |
| 14 import android.view.ViewConfiguration; | 15 import android.view.ViewConfiguration; |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * This class is responsible for handling Touch input from the user. Touch even
ts which manipulate | 18 * This class is responsible for handling Touch input from the user. Touch even
ts which manipulate |
| 18 * the local canvas are handled in this class and any input which should be sent
to the remote host | 19 * the local canvas are handled in this class and any input which should be sent
to the remote host |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 int button = mouseButtonFromPointerCount(pointerCount); | 520 int button = mouseButtonFromPointerCount(pointerCount); |
| 520 if (button == BUTTON_UNDEFINED) { | 521 if (button == BUTTON_UNDEFINED) { |
| 521 return false; | 522 return false; |
| 522 } | 523 } |
| 523 | 524 |
| 524 if (!mInputStrategy.isIndirectInputMode()) { | 525 if (!mInputStrategy.isIndirectInputMode()) { |
| 525 moveCursorToScreenPoint(x, y); | 526 moveCursorToScreenPoint(x, y); |
| 526 } | 527 } |
| 527 | 528 |
| 528 if (mInputStrategy.onTap(button)) { | 529 if (mInputStrategy.onTap(button)) { |
| 529 mViewer.showInputFeedback(mInputStrategy.getShortPressFeedbackTy
pe()); | 530 Point pos; |
| 531 synchronized (mRenderData) { |
| 532 pos = mRenderData.getCursorPosition(); |
| 533 } |
| 534 mViewer.showInputFeedback(mInputStrategy.getShortPressFeedbackTy
pe(), pos); |
| 530 } | 535 } |
| 531 return true; | 536 return true; |
| 532 } | 537 } |
| 533 | 538 |
| 534 /** Called when a long-press is triggered for one or more fingers. */ | 539 /** Called when a long-press is triggered for one or more fingers. */ |
| 535 @Override | 540 @Override |
| 536 public void onLongPress(int pointerCount, float x, float y) { | 541 public void onLongPress(int pointerCount, float x, float y) { |
| 537 int button = mouseButtonFromPointerCount(pointerCount); | 542 int button = mouseButtonFromPointerCount(pointerCount); |
| 538 if (button == BUTTON_UNDEFINED) { | 543 if (button == BUTTON_UNDEFINED) { |
| 539 return; | 544 return; |
| 540 } | 545 } |
| 541 | 546 |
| 542 if (!mInputStrategy.isIndirectInputMode()) { | 547 if (!mInputStrategy.isIndirectInputMode()) { |
| 543 moveCursorToScreenPoint(x, y); | 548 moveCursorToScreenPoint(x, y); |
| 544 } | 549 } |
| 545 | 550 |
| 546 if (mInputStrategy.onPressAndHold(button)) { | 551 if (mInputStrategy.onPressAndHold(button)) { |
| 547 mViewer.showInputFeedback(mInputStrategy.getLongPressFeedbackTyp
e()); | 552 Point pos; |
| 553 synchronized (mRenderData) { |
| 554 pos = mRenderData.getCursorPosition(); |
| 555 } |
| 556 mViewer.showInputFeedback(mInputStrategy.getLongPressFeedbackTyp
e(), pos); |
| 548 mSuppressFling = true; | 557 mSuppressFling = true; |
| 549 mIsDragging = true; | 558 mIsDragging = true; |
| 550 } | 559 } |
| 551 } | 560 } |
| 552 | 561 |
| 553 /** Maps the number of fingers in a tap or long-press gesture to a mouse
-button. */ | 562 /** Maps the number of fingers in a tap or long-press gesture to a mouse
-button. */ |
| 554 private int mouseButtonFromPointerCount(int pointerCount) { | 563 private int mouseButtonFromPointerCount(int pointerCount) { |
| 555 switch (pointerCount) { | 564 switch (pointerCount) { |
| 556 case 1: | 565 case 1: |
| 557 return BUTTON_LEFT; | 566 return BUTTON_LEFT; |
| 558 case 2: | 567 case 2: |
| 559 return BUTTON_RIGHT; | 568 return BUTTON_RIGHT; |
| 560 case 3: | 569 case 3: |
| 561 return BUTTON_MIDDLE; | 570 return BUTTON_MIDDLE; |
| 562 default: | 571 default: |
| 563 return BUTTON_UNDEFINED; | 572 return BUTTON_UNDEFINED; |
| 564 } | 573 } |
| 565 } | 574 } |
| 566 } | 575 } |
| 567 } | 576 } |
| OLD | NEW |