diff options
author | joedow <joedow@chromium.org> | 2015-12-09 08:23:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 16:24:27 +0000 |
commit | c6c60dd07b7351381b4e65dd2c85a93a064b70dd (patch) | |
tree | 2da9bfaf68c6292842435d3e52a570cf32a415ec /remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java | |
parent | 2c9be589e5244cedb5c85f09004e88ae3ad8a29c (diff) | |
download | chromium_src-c6c60dd07b7351381b4e65dd2c85a93a064b70dd.zip chromium_src-c6c60dd07b7351381b4e65dd2c85a93a064b70dd.tar.gz chromium_src-c6c60dd07b7351381b4e65dd2c85a93a064b70dd.tar.bz2 |
Update InputStrategyInterface to support new input strategies.
Updated the InputStrategyInterface to be less imperative. The interface
now has method names which are used to notify the InputStrategy instead
of methods which are used to tell it to perform a certain action.
Input strategies can now maintain their own internal state as needed
and can react, or not, to the events as they occur.
This flexibility allows the majority of the input logic to remain in the
containing class (of the input strategy) and forward gesture data to the
input strategy to allow it to react and inject the appropriate events on
the remote OS.
As a result of the change in the interface, some logic which was driven
by old interface properties/methods was updated. These changes were
part of a larger CL and were broken out to make the CL simpler.
BUG=454549
Review URL: https://codereview.chromium.org/1512753002
Cr-Commit-Position: refs/heads/master@{#364075}
Diffstat (limited to 'remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java')
-rw-r--r-- | remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java b/remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java index 1048f51..4f39962 100644 --- a/remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java +++ b/remoting/android/java/src/org/chromium/chromoting/InputStrategyInterface.java @@ -4,33 +4,74 @@ package org.chromium.chromoting; +import android.view.MotionEvent; + /** * This interface defines the methods used to customize input handling for * a particular strategy. The implementing class is responsible for sending * remote input events and defining implementation specific behavior. */ public interface InputStrategyInterface { - /** Sends a pointer move event to the remote host. */ - void injectRemoteMoveEvent(int x, int y); + /** + * Called when a user tap has been detected. + * + * @param button The button value for the tap event. + * @return A boolean representing whether the event was handled. + */ + boolean onTap(int button); + + /** + * Called when the user has put one or more fingers down on the screen for a period of time. + * + * @param button The button value for the tap event. + * @return A boolean representing whether the event was handled. + */ + boolean onPressAndHold(int button); + + /** + * Called when a MotionEvent is received. This method allows the input strategy to store or + * react to specific MotionEvents as needed. + * + * @param event The original event for the current touch motion. + */ + void onMotionEvent(MotionEvent event); - /** Sends a pointer button event to the remote host. */ - void injectRemoteButtonEvent(int button, boolean pressed); + /** + * Called when the user is attempting to scroll/pan the remote UI. + * + * @param distanceX The distance moved along the x-axis. + * @param distanceY The distance moved along the y-axis. + */ + void onScroll(float distanceX, float distanceY); - /** Sends a scroll/pan event to the remote host. */ - void injectRemoteScrollEvent(int deltaX, int deltaY); + /** + * Called to update the remote cursor position. + * + * @param x The new x coordinate of the cursor. + * @param y The new y coordinate of the cursor. + */ + void injectCursorMoveEvent(int x, int y); - /** Returns the feedback animation type to use for a short press. */ + /** + * Returns the feedback animation type to use for a short press. + * + * @return The feedback to display when a short press occurs. + */ DesktopView.InputFeedbackType getShortPressFeedbackType(); - /** Returns the feedback animation type to use for a long press. */ + /** + * Returns the feedback animation type to use for a long press. + * + * @return The feedback to display when a long press occurs. + */ DesktopView.InputFeedbackType getLongPressFeedbackType(); /** - * Indicates whether the view should be manipulated to keep the cursor in the center or if the - * view and cursor are not linked. + * Indicates whether this input mode is an indirect input mode. Indirect input modes manipulate + * the cursor in a detached fashion (such as a trackpad) and direct input modes will update the + * cursor/screen position to match the location of the touch point. + * + * @return A boolean representing whether this input mode is indirect (true) or direct (false). */ - boolean centerCursorInView(); - - /** Indicates whether to invert cursor movement for panning/scrolling. */ - boolean invertCursorMovement(); + boolean isIndirectInputMode(); } |