From a0c224dba74a5b93f59b85afb372ea8aa4f4121a Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Tue, 28 Sep 2021 09:09:47 +0800 Subject: [PATCH] Fix surface got offsetted twice while entering split Split surface might be offsetted twice by RemoteAnimationController and StageCoordinator#onStageVisibilityChanged. This removes surface positioning from onStageVisibilityChanged because the split surface should have been offsetted already by remote animation. Bug: 199377815 Test: atest WMShellUnitTests Test: trigger split from recent shortcut, observed split surfces are placed properly. Test: drag to split, observed split surfaces been placed correctly. Test: shell cmd to split, observed split surfaces been placed correctly. Change-Id: I2ae1223eec130fa849e2aaa6d2e73ec3c9a845f2 --- .../shell/splitscreen/StageCoordinator.java | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index 493870d7fd728..a046c42b2391c 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -250,7 +250,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, setSideStagePosition(sideStagePosition, wct); mMainStage.activate(getMainStageBounds(), wct); mSideStage.addTask(task, getSideStageBounds(), wct); - mTaskOrganizer.applyTransaction(wct); + mSyncQueue.queue(wct); + mSyncQueue.runInSync(t -> updateSurfaceBounds(null /* layout */, t)); return true; } @@ -446,15 +447,15 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, setSideStagePosition(sideStagePosition, true /* updateBounds */, wct); } - private void setSideStagePosition(@SplitPosition int sideStagePosition, - boolean updateBounds, @Nullable WindowContainerTransaction wct) { + private void setSideStagePosition(@SplitPosition int sideStagePosition, boolean updateBounds, + @Nullable WindowContainerTransaction wct) { if (mSideStagePosition == sideStagePosition) return; mSideStagePosition = sideStagePosition; sendOnStagePositionChanged(); if (mSideStageListener.mVisible && updateBounds) { if (wct == null) { - // onBoundsChanged builds/applies a wct with the contents of updateWindowBounds. + // onLayoutChanged builds/applies a wct with the contents of updateWindowBounds. onLayoutChanged(mSplitLayout); } else { updateWindowBounds(mSplitLayout, wct); @@ -675,29 +676,11 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, } mSyncQueue.runInSync(t -> { - final SurfaceControl sideStageLeash = mSideStage.mRootLeash; - final SurfaceControl mainStageLeash = mMainStage.mRootLeash; - - if (sideStageVisible) { - final Rect sideStageBounds = getSideStageBounds(); - t.setPosition(sideStageLeash, - sideStageBounds.left, sideStageBounds.top) - .setWindowCrop(sideStageLeash, - sideStageBounds.width(), sideStageBounds.height()); - } - - if (mainStageVisible) { - final Rect mainStageBounds = getMainStageBounds(); - t.setPosition(mainStageLeash, mainStageBounds.left, mainStageBounds.top) - .setWindowCrop(mainStageLeash, - mainStageBounds.width(), mainStageBounds.height()); - } - // Same above, we only set root tasks and divider leash visibility when both stage // change to visible or invisible to avoid flicker. if (sameVisibility) { - t.setVisibility(sideStageLeash, bothStageVisible) - .setVisibility(mainStageLeash, bothStageVisible); + t.setVisibility(mSideStage.mRootLeash, bothStageVisible) + .setVisibility(mMainStage.mRootLeash, bothStageVisible); applyDividerVisibility(t); } });