diff options
| author | 2019-03-17 22:46:08 +0000 | |
|---|---|---|
| committer | 2019-03-17 22:46:08 +0000 | |
| commit | 6b243887f3dec6eaba1101a106a8a4903dda9d37 (patch) | |
| tree | 8464b79e5c0a365aa6125d7c6d344c14a0dcc812 /services/surfaceflinger/Layer.cpp | |
| parent | 178e86bb5218595d9fe20d7aa94a89df5b62028d (diff) | |
| parent | 6fabeece7fd6d858699af99cb118e63b8a81147b (diff) | |
Merge "Input: Override touchable region bounds with surface bounds 2/2"
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index ef9418c952..16e69b9b26 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -1796,8 +1796,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); @@ -1986,6 +2002,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; } |