Crop bounds sent to input by screen bounds.
We want to the frame sent to input to be the layer bounds, including
crop. This is because if the layer is cropped, we don't need to consider
the cropped area on screen and therefore will not affect the touch area.
Test: Minimized split has correct input frame
Test: InputSurfacesTest.*
Fixes: 170871385
Fixes: 171756624
Change-Id: I3d00f98044a68de6596265bc3e444d3ed2ea5896
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index b60acde..9481966 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2495,12 +2495,6 @@
transformedLayerBounds.bottom = tmp;
}
- // Input coordinates should be in display coordinate space.
- info.frameLeft = transformedLayerBounds.left;
- info.frameTop = transformedLayerBounds.top;
- info.frameRight = transformedLayerBounds.right;
- info.frameBottom = transformedLayerBounds.bottom;
-
// Compute the correct transform to send to input. This will allow it to transform the
// input coordinates from display space into window space. Therefore, it needs to use the
// final layer frame to create the inverse transform. Since surface insets are added later,
@@ -2522,6 +2516,16 @@
inputTransform.set(translation.x, translation.y);
info.transform = inputTransform.inverse();
+ // We need to send the layer bounds cropped to the screenbounds since the layer can be cropped.
+ // The frame should be the area the user sees on screen since it's used for occlusion
+ // detection.
+ Rect screenBounds = Rect{mScreenBounds};
+ transformedLayerBounds.intersect(screenBounds, &transformedLayerBounds);
+ info.frameLeft = transformedLayerBounds.left;
+ info.frameTop = transformedLayerBounds.top;
+ info.frameRight = transformedLayerBounds.right;
+ info.frameBottom = transformedLayerBounds.bottom;
+
// Position the touchable region relative to frame screen location and restrict it to frame
// bounds.
info.touchableRegion = inputTransform.transform(info.touchableRegion);