@@ -190,6 +190,9 @@ public class TouchExplorer {
190190 // The long pressing pointer Y if coordinate remapping is needed.
191191 private int mLongPressingPointerDeltaY ;
192192
193+ // The id of the last touch explored window.
194+ private int mLastTouchedWindowId ;
195+
193196 /**
194197 * Creates a new instance.
195198 *
@@ -305,6 +308,11 @@ public void onAccessibilityEvent(AccessibilityEvent event) {
305308 mInjectedPointerTracker .mLastInjectedHoverEvent .recycle ();
306309 mInjectedPointerTracker .mLastInjectedHoverEvent = null ;
307310 }
311+ mLastTouchedWindowId = -1 ;
312+ } break ;
313+ case AccessibilityEvent .TYPE_VIEW_HOVER_ENTER :
314+ case AccessibilityEvent .TYPE_VIEW_HOVER_EXIT : {
315+ mLastTouchedWindowId = event .getWindowId ();
308316 } break ;
309317 }
310318 }
@@ -1078,13 +1086,15 @@ public void onDoubleTap(MotionEvent secondTapUp, int policyFlags) {
10781086 clickLocationX = (int ) lastExploreEvent .getX (lastExplorePointerIndex );
10791087 clickLocationY = (int ) lastExploreEvent .getY (lastExplorePointerIndex );
10801088 Rect activeWindowBounds = mTempRect ;
1081- mAms .getActiveWindowBounds (activeWindowBounds );
1082- if (activeWindowBounds .contains (clickLocationX , clickLocationY )) {
1083- Rect focusBounds = mTempRect ;
1084- if (mAms .getAccessibilityFocusBoundsInActiveWindow (focusBounds )) {
1085- if (!focusBounds .contains (clickLocationX , clickLocationY )) {
1086- clickLocationX = focusBounds .centerX ();
1087- clickLocationY = focusBounds .centerY ();
1089+ if (mLastTouchedWindowId == mAms .getActiveWindowId ()) {
1090+ mAms .getActiveWindowBounds (activeWindowBounds );
1091+ if (activeWindowBounds .contains (clickLocationX , clickLocationY )) {
1092+ Rect focusBounds = mTempRect ;
1093+ if (mAms .getAccessibilityFocusBoundsInActiveWindow (focusBounds )) {
1094+ if (!focusBounds .contains (clickLocationX , clickLocationY )) {
1095+ clickLocationX = focusBounds .centerX ();
1096+ clickLocationY = focusBounds .centerY ();
1097+ }
10881098 }
10891099 }
10901100 }
@@ -1308,13 +1318,15 @@ public void run() {
13081318 clickLocationX = (int ) lastExploreEvent .getX (lastExplorePointerIndex );
13091319 clickLocationY = (int ) lastExploreEvent .getY (lastExplorePointerIndex );
13101320 Rect activeWindowBounds = mTempRect ;
1311- mAms .getActiveWindowBounds (activeWindowBounds );
1312- if (activeWindowBounds .contains (clickLocationX , clickLocationY )) {
1313- Rect focusBounds = mTempRect ;
1314- if (mAms .getAccessibilityFocusBoundsInActiveWindow (focusBounds )) {
1315- if (!focusBounds .contains (clickLocationX , clickLocationY )) {
1316- clickLocationX = focusBounds .centerX ();
1317- clickLocationY = focusBounds .centerY ();
1321+ if (mLastTouchedWindowId == mAms .getActiveWindowId ()) {
1322+ mAms .getActiveWindowBounds (activeWindowBounds );
1323+ if (activeWindowBounds .contains (clickLocationX , clickLocationY )) {
1324+ Rect focusBounds = mTempRect ;
1325+ if (mAms .getAccessibilityFocusBoundsInActiveWindow (focusBounds )) {
1326+ if (!focusBounds .contains (clickLocationX , clickLocationY )) {
1327+ clickLocationX = focusBounds .centerX ();
1328+ clickLocationY = focusBounds .centerY ();
1329+ }
13181330 }
13191331 }
13201332 }
0 commit comments