diff options
| author | Vladislav Kaznacheev <kaznacheev@google.com> | 2016-10-10 16:11:15 -0700 |
|---|---|---|
| committer | Vladislav Kaznacheev <kaznacheev@google.com> | 2016-10-10 16:11:15 -0700 |
| commit | 5a77c3748817eb120fc6c988ccfe2d31069f6325 (patch) | |
| tree | c3fd5fb2d9b796ff1a9ec272f5d402b04558e262 /core/java/android/view/MotionEvent.java | |
| parent | 251a9e689e86ec868812e26eee04afc80bb32d1b (diff) | |
Avoid sending incorrect or redundant hover events.
Make sure ACTION_HOVER_EXIT is never sent to a
ViewGroup more than once.
While processing ACTION_HOVER_MOVE during exiting
a hover target never send it a ACTION_HOVER_ENTER.
Test: android.view.cts.HoverTest
Bug: 32071138
Bug: 32071098
Change-Id: Ibc1809137907176437a3a5a4ea14b00f1c629b58
Diffstat (limited to 'core/java/android/view/MotionEvent.java')
| -rw-r--r-- | core/java/android/view/MotionEvent.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 3e8d5777bfa6..2316b3829f37 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -436,6 +436,14 @@ public final class MotionEvent extends InputEvent implements Parcelable { public static final int FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2; /** + * This private flag is only set on {@link #ACTION_HOVER_MOVE} events and indicates that + * this event will be immediately followed by a {@link #ACTION_HOVER_EXIT}. It is used to + * prevent generating redundant {@link #ACTION_HOVER_ENTER} events. + * @hide + */ + public static final int FLAG_HOVER_EXIT_PENDING = 0x4; + + /** * Private flag that indicates when the system has detected that this motion event * may be inconsistent with respect to the sequence of previously delivered motion events, * such as when a pointer move event is sent but the pointer is not down. @@ -1947,6 +1955,20 @@ public final class MotionEvent extends InputEvent implements Parcelable { : flags & ~FLAG_TARGET_ACCESSIBILITY_FOCUS); } + /** @hide */ + public final boolean isHoverExitPending() { + final int flags = getFlags(); + return (flags & FLAG_HOVER_EXIT_PENDING) != 0; + } + + /** @hide */ + public void setHoverExitPending(boolean hoverExitPending) { + final int flags = getFlags(); + nativeSetFlags(mNativePtr, hoverExitPending + ? flags | FLAG_HOVER_EXIT_PENDING + : flags & ~FLAG_HOVER_EXIT_PENDING); + } + /** * Returns the time (in ms) when the user originally pressed down to start * a stream of position events. |
