Only use surface based touchable region for updating input window
The usages of magnification, touch-exclude-region, drag-and-drop,
window info for accessibility still need the real position on screen.
Bug: 120242516
Test: atest LoginActivityTest#testSaveOnly
Change-Id: I49f8b5d0481fa3ffdec70aecac0f10da6e2284b6
diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java
index 88b22cb..c1e9a73 100644
--- a/services/core/java/com/android/server/wm/InputMonitor.java
+++ b/services/core/java/com/android/server/wm/InputMonitor.java
@@ -194,7 +194,7 @@
final boolean hasFocus, final boolean hasWallpaper) {
// Add a window to our list of input windows.
inputWindowHandle.name = child.toString();
- flags = child.getTouchableRegion(inputWindowHandle.touchableRegion, flags);
+ flags = child.getSurfaceTouchableRegion(inputWindowHandle.touchableRegion, flags);
inputWindowHandle.layoutParamsFlags = flags;
inputWindowHandle.layoutParamsType = type;
inputWindowHandle.dispatchingTimeoutNanos = child.getInputDispatchingTimeoutNanos();
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index cdf9118..2d47e54 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2145,7 +2145,7 @@
}
}
- int getTouchableRegion(Region region, int flags) {
+ int getSurfaceTouchableRegion(Region region, int flags) {
final boolean modal = (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0;
if (modal && mAppToken != null) {
// Limit the outer touch to the activity stack region.
@@ -2173,7 +2173,7 @@
region.translate(-mWindowFrames.mFrame.left, -mWindowFrames.mFrame.top);
} else {
// Not modal or full screen modal
- getTouchableRegion(region);
+ getTouchableRegion(region, true /* forSurface */);
}
// The area containing the shadows is not touchable.
@@ -2810,7 +2810,13 @@
frame.right - inset.right, frame.bottom - inset.bottom);
}
+ /** Get the touchable region in global coordinates. */
void getTouchableRegion(Region outRegion) {
+ getTouchableRegion(outRegion, false /* forSurface */);
+ }
+
+ /** If {@param forSuface} is {@code true}, the region will be translated to surface based. */
+ private void getTouchableRegion(Region outRegion, boolean forSurface) {
if (inPinnedWindowingMode() && !isFocused()) {
outRegion.setEmpty();
return;
@@ -2821,22 +2827,26 @@
default:
case TOUCHABLE_INSETS_FRAME:
outRegion.set(frame);
- outRegion.translate(-frame.left, -frame.top);
break;
case TOUCHABLE_INSETS_CONTENT:
applyInsets(outRegion, frame, mGivenContentInsets);
- outRegion.translate(-frame.left, -frame.top);
break;
case TOUCHABLE_INSETS_VISIBLE:
applyInsets(outRegion, frame, mGivenVisibleInsets);
- outRegion.translate(-frame.left, -frame.top);
break;
case TOUCHABLE_INSETS_REGION: {
outRegion.set(mGivenTouchableRegion);
break;
}
}
- outRegion.translate(mAttrs.surfaceInsets.left, mAttrs.surfaceInsets.top);
+
+ if (forSurface) {
+ if (mTouchableInsets != TOUCHABLE_INSETS_REGION) {
+ outRegion.translate(-frame.left, -frame.top);
+ }
+ outRegion.getBounds(mTmpRect);
+ applyInsets(outRegion, mTmpRect, mAttrs.surfaceInsets);
+ }
}
private void cropRegionToStackBoundsIfNeeded(Region region) {