From 75a8847a425a84614698dbbab3a38c055a2569f6 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Mon, 28 Nov 2022 10:28:13 -0800 Subject: [PATCH] Fix detection supportsHover Summary: Changelog: [Internal] - Internal usage broke existing behavior, reverting to check if a flag is set. Reviewed By: javache Differential Revision: D41502122 fbshipit-source-id: 296bb1578cd63f935e4111bfec8d58f965149640 --- .../react/uimanager/events/PointerEventHelper.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java index da6b77cd1a2..544a9e8a31c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java @@ -22,6 +22,7 @@ public class PointerEventHelper { public static final String POINTER_TYPE_PEN = "pen"; public static final String POINTER_TYPE_MOUSE = "mouse"; public static final String POINTER_TYPE_UNKNOWN = ""; + private static final int X_FLAG_SUPPORTS_HOVER = 0x01000000; public static enum EVENT { CANCEL, @@ -184,8 +185,17 @@ public class PointerEventHelper { } public static boolean supportsHover(MotionEvent motionEvent) { + // A flag has been set on the MotionEvent to indicate it supports hover + // See D36958947 on justifications for this. + // TODO(luwe): Leverage previous events to determine if MotionEvent + // is from an input device that supports hover + boolean supportsHoverFlag = (motionEvent.getFlags() & X_FLAG_SUPPORTS_HOVER) != 0; + if (supportsHoverFlag) { + return true; + } + int source = motionEvent.getSource(); - return source == InputDevice.SOURCE_MOUSE || source == InputDevice.SOURCE_CLASS_POINTER; + return source == InputDevice.SOURCE_MOUSE; } public static boolean isExitEvent(String eventName) {