| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.graphics.PointF; | 7 import android.graphics.PointF; |
| 8 import android.view.MotionEvent; | 8 import android.view.MotionEvent; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Defines a set of behavior and methods to simulate trackpad behavior when resp
onding to | 11 * Defines a set of behavior and methods to simulate trackpad behavior when resp
onding to |
| 12 * local input event data. This class is also responsible for forwarding input
event data | 12 * local input event data. This class is also responsible for forwarding input
event data |
| 13 * to the remote host for injection there. | 13 * to the remote host for injection there. |
| 14 */ | 14 */ |
| 15 public class TrackpadInputStrategy implements InputStrategyInterface { | 15 public class TrackpadInputStrategy implements InputStrategyInterface { |
| 16 private final RenderData mRenderData; | 16 private final RenderData mRenderData; |
| 17 private final InputEventSender mInjector; | 17 private final InputEventSender mInjector; |
| 18 | 18 |
| 19 /** Mouse-button currently held down, or BUTTON_UNDEFINED otherwise. */ | 19 /** Mouse-button currently held down, or BUTTON_UNDEFINED otherwise. */ |
| 20 private int mHeldButton = InputStub.BUTTON_UNDEFINED; | 20 private int mHeldButton = InputStub.BUTTON_UNDEFINED; |
| 21 | 21 |
| 22 public TrackpadInputStrategy(RenderData renderData, InputEventSender injecto
r) { | 22 public TrackpadInputStrategy(RenderData renderData, InputEventSender injecto
r) { |
| 23 Preconditions.notNull(injector); | 23 Preconditions.notNull(injector); |
| 24 mRenderData = renderData; | 24 mRenderData = renderData; |
| 25 mInjector = injector; | 25 mInjector = injector; |
| 26 | 26 |
| 27 synchronized (mRenderData) { | 27 mRenderData.drawCursor = true; |
| 28 mRenderData.drawCursor = true; | |
| 29 } | |
| 30 } | 28 } |
| 31 | 29 |
| 32 @Override | 30 @Override |
| 33 public boolean onTap(int button) { | 31 public boolean onTap(int button) { |
| 34 mInjector.sendMouseClick(getCursorPosition(), button); | 32 mInjector.sendMouseClick(getCursorPosition(), button); |
| 35 return true; | 33 return true; |
| 36 } | 34 } |
| 37 | 35 |
| 38 @Override | 36 @Override |
| 39 public boolean onPressAndHold(int button) { | 37 public boolean onPressAndHold(int button) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 70 public DesktopView.InputFeedbackType getLongPressFeedbackType() { | 68 public DesktopView.InputFeedbackType getLongPressFeedbackType() { |
| 71 return DesktopView.InputFeedbackType.SMALL_ANIMATION; | 69 return DesktopView.InputFeedbackType.SMALL_ANIMATION; |
| 72 } | 70 } |
| 73 | 71 |
| 74 @Override | 72 @Override |
| 75 public boolean isIndirectInputMode() { | 73 public boolean isIndirectInputMode() { |
| 76 return true; | 74 return true; |
| 77 } | 75 } |
| 78 | 76 |
| 79 private PointF getCursorPosition() { | 77 private PointF getCursorPosition() { |
| 80 synchronized (mRenderData) { | 78 return mRenderData.getCursorPosition(); |
| 81 return mRenderData.getCursorPosition(); | |
| 82 } | |
| 83 } | 79 } |
| 84 } | 80 } |
| OLD | NEW |