diff options
| author | Tiger Huang <tigerhuang@google.com> | 2019-04-18 14:35:09 -0700 |
|---|---|---|
| committer | Tiger Huang <tigerhuang@google.com> | 2019-05-02 12:53:55 +0800 |
| commit | d8ec93860957c95d00b1c1fa18ba2f302d06720e (patch) | |
| tree | b494ba05fc7531b98a1c1cf857ee2a83418b1873 /core/java/android/app/ActivityView.java | |
| parent | 81894407855a3a4769b966f857ea867092c358ac (diff) | |
Refine getTransformationMatrix for windows in a re-parented display
Currently, the translation of the transformation matrix computed by
WindowState.getTransformationMatrix is related to its own display.
However, if the display has been re-parented, the translation might
be misplaced to the visual result. This CL makes it return the global
transformation matrix.
Bug: 129098348
Test: atest WindowStateTests
Change-Id: I38da5b84a11890bf0f4a57eb9d5b7e71bdcc16a9
Diffstat (limited to 'core/java/android/app/ActivityView.java')
| -rw-r--r-- | core/java/android/app/ActivityView.java | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index fc6fffabc917..b64b2dcc4f61 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -317,7 +317,7 @@ public class ActivityView extends ViewGroup { * regions and avoid focus switches by touches on this view. */ public void onLocationChanged() { - updateTapExcludeRegion(); + updateLocationAndTapExcludeRegion(); } @Override @@ -329,39 +329,52 @@ public class ActivityView extends ViewGroup { public boolean gatherTransparentRegion(Region region) { // The tap exclude region may be affected by any view on top of it, so we detect the // possible change by monitoring this function. - updateTapExcludeRegion(); + updateLocationAndTapExcludeRegion(); return super.gatherTransparentRegion(region); } - /** Compute and send current tap exclude region to WM for this view. */ - private void updateTapExcludeRegion() { - if (!isAttachedToWindow()) { - return; - } - if (!canReceivePointerEvents()) { - cleanTapExcludeRegion(); + /** + * Sends current location in window and tap exclude region to WM for this view. + */ + private void updateLocationAndTapExcludeRegion() { + if (mVirtualDisplay == null || !isAttachedToWindow()) { return; } try { + int x = mLocationInWindow[0]; + int y = mLocationInWindow[1]; getLocationInWindow(mLocationInWindow); - final int x = mLocationInWindow[0]; - final int y = mLocationInWindow[1]; - mTapExcludeRegion.set(x, y, x + getWidth(), y + getHeight()); - - // There might be views on top of us. We need to subtract those areas from the tap - // exclude region. - final ViewParent parent = getParent(); - if (parent instanceof ViewGroup) { - ((ViewGroup) parent).subtractObscuredTouchableRegion(mTapExcludeRegion, this); + if (x != mLocationInWindow[0] || y != mLocationInWindow[1]) { + x = mLocationInWindow[0]; + y = mLocationInWindow[1]; + WindowManagerGlobal.getWindowSession().updateDisplayContentLocation( + getWindow(), x, y, mVirtualDisplay.getDisplay().getDisplayId()); } - - WindowManagerGlobal.getWindowSession().updateTapExcludeRegion(getWindow(), hashCode(), - mTapExcludeRegion); + updateTapExcludeRegion(x, y); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } } + /** Computes and sends current tap exclude region to WM for this view. */ + private void updateTapExcludeRegion(int x, int y) throws RemoteException { + if (!canReceivePointerEvents()) { + cleanTapExcludeRegion(); + return; + } + mTapExcludeRegion.set(x, y, x + getWidth(), y + getHeight()); + + // There might be views on top of us. We need to subtract those areas from the tap + // exclude region. + final ViewParent parent = getParent(); + if (parent != null) { + parent.subtractObscuredTouchableRegion(mTapExcludeRegion, this); + } + + WindowManagerGlobal.getWindowSession().updateTapExcludeRegion(getWindow(), hashCode(), + mTapExcludeRegion); + } + private class SurfaceCallback implements SurfaceHolder.Callback { @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { @@ -379,7 +392,7 @@ public class ActivityView extends ViewGroup { mVirtualDisplay.setDisplayState(true); } - updateTapExcludeRegion(); + updateLocationAndTapExcludeRegion(); } @Override @@ -387,7 +400,7 @@ public class ActivityView extends ViewGroup { if (mVirtualDisplay != null) { mVirtualDisplay.resize(width, height, getBaseDisplayDensity()); } - updateTapExcludeRegion(); + updateLocationAndTapExcludeRegion(); } @Override @@ -471,7 +484,8 @@ public class ActivityView extends ViewGroup { try { // TODO: Find a way to consolidate these calls to the server. - wm.reparentDisplayContent(displayId, mRootSurfaceControl); + WindowManagerGlobal.getWindowSession().reparentDisplayContent( + getWindow(), mRootSurfaceControl, displayId); wm.dontOverrideDisplayInfo(displayId); if (mSingleTaskInstance) { mActivityTaskManager.setDisplayToSingleTaskInstance(displayId); |
