diff options
author | Andrii Kulian <akulian@google.com> | 2018-09-14 16:48:08 -0700 |
---|---|---|
committer | Arthur Hung <arthurhung@google.com> | 2018-12-10 21:01:05 +0800 |
commit | 84cdf9cc3b849679e6b4f6d3ccb66270f0abad2f (patch) | |
tree | 0f71df4df15e08b540a842ac7ed4aa7e6e743be1 /libs/input/SpriteController.cpp | |
parent | 9be59f96b3385e8b9c39c5bee303a3e19a0d960f (diff) |
Support mouse pointer on external displays (2/3)
Limit mouse boundary to one display viewport.
Currently if desktop mode is enable, selects the topmost freeform display,
or find first external display if there is no freeform display.
Return the default display if desktop mode is not enable.
- Add getPointerDisplayId to find the preferred display.
- Limit update viewports from InputReader. Also implements updatePointerDisplay
to find and associate with the specified display viewport.
- Reload cursor resources if resolution or display changed.
Bug: 113559891
Test: atest inputfliger_tests
Test: ActivityView test app
Change-Id: Ief3410a517be457dfe6f1180342bb1dc88833635
Diffstat (limited to 'libs/input/SpriteController.cpp')
-rw-r--r-- | libs/input/SpriteController.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp index eb2bc98ec9e9..c1868d3a94d6 100644 --- a/libs/input/SpriteController.cpp +++ b/libs/input/SpriteController.cpp @@ -144,13 +144,16 @@ void SpriteController::doUpdateSprites() { } } - // Resize sprites if needed. + // Resize and/or reparent sprites if needed. SurfaceComposerClient::Transaction t; bool needApplyTransaction = false; for (size_t i = 0; i < numSprites; i++) { SpriteUpdate& update = updates.editItemAt(i); + if (update.state.surfaceControl == nullptr) { + continue; + } - if (update.state.surfaceControl != NULL && update.state.wantSurfaceVisible()) { + if (update.state.wantSurfaceVisible()) { int32_t desiredWidth = update.state.icon.bitmap.width(); int32_t desiredHeight = update.state.icon.bitmap.height(); if (update.state.surfaceWidth < desiredWidth @@ -170,6 +173,12 @@ void SpriteController::doUpdateSprites() { } } } + + // If surface is a new one, we have to set right layer stack. + if (update.surfaceChanged || update.state.dirty & DIRTY_DISPLAY_ID) { + t.setLayerStack(update.state.surfaceControl, update.state.displayId); + needApplyTransaction = true; + } } if (needApplyTransaction) { t.apply(); @@ -236,7 +245,7 @@ void SpriteController::doUpdateSprites() { if (update.state.surfaceControl != NULL && (becomingVisible || becomingHidden || (wantSurfaceVisibleAndDrawn && (update.state.dirty & (DIRTY_ALPHA | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER - | DIRTY_VISIBILITY | DIRTY_HOTSPOT))))) { + | DIRTY_VISIBILITY | DIRTY_HOTSPOT | DIRTY_DISPLAY_ID))))) { needApplyTransaction = true; if (wantSurfaceVisibleAndDrawn @@ -445,6 +454,15 @@ void SpriteController::SpriteImpl::setTransformationMatrix( } } +void SpriteController::SpriteImpl::setDisplayId(int32_t displayId) { + AutoMutex _l(mController->mLock); + + if (mLocked.state.displayId != displayId) { + mLocked.state.displayId = displayId; + invalidateLocked(DIRTY_DISPLAY_ID); + } +} + void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) { bool wasDirty = mLocked.state.dirty; mLocked.state.dirty |= dirty; |