diff options
| author | 2021-07-27 14:34:11 +0800 | |
|---|---|---|
| committer | 2021-11-16 14:46:56 +0800 | |
| commit | 04e3ea9b85e7b6383da6f02bc9ad189a3fccadd0 (patch) | |
| tree | 4c817ca30d240407e43f6dede4813826caa5c124 | |
| parent | f322e418ced0a08294c0a5ecbe9a85d1a1599ff4 (diff) | |
Adjust the click point when magnification is activated
After ag/5612023, the click point calculation should depend on
the global screen coordinate instead of the coordinate before
magnification.
Bug: 193200262
Test: manual test on launcher
Change-Id: If51885f43e78c1554fdcd0642fb301a466d3bdba
| -rw-r--r-- | services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java index 0e3932799123..a11e2641e5c9 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -3576,31 +3576,36 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } synchronized (mLock) { - Rect boundsInScreen = mTempRect; - focus.getBoundsInScreen(boundsInScreen); + Rect boundsInScreenBeforeMagnification = mTempRect; - // Apply magnification if needed. + focus.getBoundsInScreen(boundsInScreenBeforeMagnification); + final Point nodeCenter = new Point(boundsInScreenBeforeMagnification.centerX(), + boundsInScreenBeforeMagnification.centerY()); + + // Invert magnification if needed. MagnificationSpec spec = getCompatibleMagnificationSpecLocked(focus.getWindowId()); if (spec != null && !spec.isNop()) { - boundsInScreen.offset((int) -spec.offsetX, (int) -spec.offsetY); - boundsInScreen.scale(1 / spec.scale); + boundsInScreenBeforeMagnification.offset((int) -spec.offsetX, + (int) -spec.offsetY); + boundsInScreenBeforeMagnification.scale(1 / spec.scale); } - // Clip to the window bounds. + //Clip to the window bounds. Rect windowBounds = mTempRect1; getWindowBounds(focus.getWindowId(), windowBounds); - if (!boundsInScreen.intersect(windowBounds)) { + if (!boundsInScreenBeforeMagnification.intersect(windowBounds)) { return false; } - // Clip to the screen bounds. + //Clip to the screen bounds. Point screenSize = mTempPoint; mDefaultDisplay.getRealSize(screenSize); - if (!boundsInScreen.intersect(0, 0, screenSize.x, screenSize.y)) { + if (!boundsInScreenBeforeMagnification.intersect(0, 0, screenSize.x, + screenSize.y)) { return false; } - outPoint.set(boundsInScreen.centerX(), boundsInScreen.centerY()); + outPoint.set(nodeCenter.x, nodeCenter.y); } return true; |