Added input support for cloned layers
This was done with a few changes:
1. Added a layerId in the input info so the InputInfo objects can be
uniquely identified as per layer
2. When setting input info in InputDispatcher, compare InputInfo objects
using layer id instead of input token.
3. Updated the crop region for layers based on the cloned hierarchy so
the input is cropped to the correct region.
Bug: 140756730
Test: InputDispatcherMultiWindowSameTokenTests
Change-Id: I980f5d29d091fecb407f5cd6a289615505800927
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 054acc5..bdecdb7 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -770,17 +770,20 @@
// After buffer info is updated, the drawingState from the real layer needs to be copied into
// the cloned. This is because some properties of drawingState can change when latchBuffer is
- // called. However, copying the drawingState would also overwrite the cloned layer's relatives.
- // Therefore, temporarily store the relatives so they can be set in the cloned drawingState
- // again.
+ // called. However, copying the drawingState would also overwrite the cloned layer's relatives
+ // and touchableRegionCrop. Therefore, temporarily store the relatives so they can be set in
+ // the cloned drawingState again.
wp<Layer> tmpZOrderRelativeOf = mDrawingState.zOrderRelativeOf;
SortedVector<wp<Layer>> tmpZOrderRelatives = mDrawingState.zOrderRelatives;
+ wp<Layer> tmpTouchableRegionCrop = mDrawingState.touchableRegionCrop;
+ InputWindowInfo tmpInputInfo = mDrawingState.inputInfo;
+
mDrawingState = clonedFrom->mDrawingState;
- // TODO: (b/140756730) Ignore input for now since InputDispatcher doesn't support multiple
- // InputWindows per client token yet.
- mDrawingState.inputInfo.token = nullptr;
+
+ mDrawingState.touchableRegionCrop = tmpTouchableRegionCrop;
mDrawingState.zOrderRelativeOf = tmpZOrderRelativeOf;
mDrawingState.zOrderRelatives = tmpZOrderRelatives;
+ mDrawingState.inputInfo = tmpInputInfo;
}
} // namespace android