summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/Layer.cpp
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2019-03-12 13:42:49 -0700
committer Vishnu Nair <vishnun@google.com> 2019-03-12 13:42:49 -0700
commit6fabeece7fd6d858699af99cb118e63b8a81147b (patch)
tree7845e03f33627a123ba29506c2349651a9e169fa /services/surfaceflinger/Layer.cpp
parent9f166127de7f8673d59783fb7f2f72d57f515251 (diff)
Input: Override touchable region bounds with surface bounds 2/2
Take advantage of the surface flinger layer hierarchy to set touchable region. - Let a client set a surface touchable region to its own bounds. - Let a client set a surface touchable region to another surface bounds. - Let a client bound its touchable region to a surface. Test: go/wm-smoke Test: existing tests Change-Id: I447c93353d067a296007ba8f8341d2420b941d71
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
-rw-r--r--services/surfaceflinger/Layer.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 5c3fb05744..af27ca3571 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2009,8 +2009,24 @@ void Layer::commitChildList() {
mDrawingParent = mCurrentParent;
}
+static wp<Layer> extractLayerFromBinder(const wp<IBinder>& weakBinderHandle) {
+ if (weakBinderHandle == nullptr) {
+ return nullptr;
+ }
+ sp<IBinder> binderHandle = weakBinderHandle.promote();
+ if (binderHandle == nullptr) {
+ return nullptr;
+ }
+ sp<Layer::Handle> handle = static_cast<Layer::Handle*>(binderHandle.get());
+ if (handle == nullptr) {
+ return nullptr;
+ }
+ return handle->owner;
+}
+
void Layer::setInputInfo(const InputWindowInfo& info) {
mCurrentState.inputInfo = info;
+ mCurrentState.touchableRegionCrop = extractLayerFromBinder(info.touchableRegionCropHandle);
mCurrentState.modified = true;
mCurrentState.inputInfoChanged = true;
setTransactionFlags(eTransactionNeeded);
@@ -2199,6 +2215,18 @@ InputWindowInfo Layer::fillInputInfo() {
// bounds.
info.touchableRegion = info.touchableRegion.translate(info.frameLeft, info.frameTop);
info.visible = canReceiveInput();
+
+ auto cropLayer = mDrawingState.touchableRegionCrop.promote();
+ if (info.replaceTouchableRegionWithCrop) {
+ if (cropLayer == nullptr) {
+ info.touchableRegion = Region(Rect{mScreenBounds});
+ } else {
+ info.touchableRegion = Region(Rect{cropLayer->mScreenBounds});
+ }
+ } else if (cropLayer != nullptr) {
+ info.touchableRegion = info.touchableRegion.intersect(Rect{cropLayer->mScreenBounds});
+ }
+
return info;
}