Forward input windows from SurfaceFlinger to InputDispatcher.
We re-use values from visible region computation to fill in
the frames, ensuring input always reflects the most recent
state of the scene.
Test: Extensive manual testing. Existing tests pass.
Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: I9908a1bd6cba6abf16f2f6a43b6fe63f07a124a6
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index f3182be..d9ec44a 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1057,6 +1057,11 @@
clearSyncPoints();
}
+ if (mCurrentState.inputInfoChanged) {
+ flags |= eInputInfoChanged;
+ mCurrentState.inputInfoChanged = false;
+ }
+
// Commit the transaction
commitTransaction(c);
mCurrentState.callbackHandles = {};
@@ -1928,6 +1933,13 @@
mDrawingParent = mCurrentParent;
}
+void Layer::setInputInfo(const InputWindowInfo& info) {
+ mCurrentState.inputInfo = info;
+ mCurrentState.modified = true;
+ mCurrentState.inputInfoChanged = true;
+ setTransactionFlags(eTransactionNeeded);
+}
+
void Layer::writeToProto(LayerProto* layerInfo, LayerVector::StateSet stateSet) {
const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
@@ -2055,6 +2067,24 @@
return mRemovedFromCurrentState;
}
+InputWindowInfo Layer::fillInputInfo(const Rect& screenBounds) {
+ InputWindowInfo info = mDrawingState.inputInfo;
+ info.frameLeft = screenBounds.left;
+ info.inputInfo.frameTop = screenBounds.top;
+ info.inputInfo.frameRight = screenBounds.right;
+ info.inputInfo.frameBottom = screenBounds.bottom;
+
+ info.touchableRegion = mDrawingState.inputInfo.touchableRegion.translate(
+ screenBounds.left,
+ screenBounds.top);
+ info.visible = isVisible();
+ return info;
+}
+
+bool Layer::hasInput() const {
+ return mDrawingState.inputInfo.inputChannel != nullptr;
+}
+
// ---------------------------------------------------------------------------
}; // namespace android