Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 068923f3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix z-order of displays when adjusting position of stack"

parents 7b39606e 2f6e174c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -3606,6 +3606,18 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            final int targetPosition = findPositionForStack(position, child, false /* adding */);
            super.positionChildAt(targetPosition, child, includingParents);

            if (includingParents) {
                // We still want to move the display of this stack container to top because even the
                // target position is adjusted to non-top, the intention of the condition is to have
                // higher z-order to gain focus (e.g. moving a task of a fullscreen stack to front
                // in a non-top display which is using picture-in-picture mode).
                final int topChildPosition = getChildCount() - 1;
                if (targetPosition < topChildPosition && position >= topChildPosition) {
                    getParent().positionChildAt(POSITION_TOP, this /* child */,
                            true /* includingParents */);
                }
            }

            setLayoutNeeded();
        }

+18 −0
Original line number Diff line number Diff line
@@ -109,4 +109,22 @@ public class TaskStackContainersTests extends WindowTestsBase {
        assertEquals(taskStackContainer.mChildren.get(stackPos), stack1);
        assertEquals(taskStackContainer.mChildren.get(pinnedStackPos), mPinnedStack);
    }

    @Test
    public void testDisplayPositionWithPinnedStack() {
        // The display contains pinned stack that was added in {@link #setUp}.
        final TaskStack stack = createTaskStackOnDisplay(mDisplayContent);
        final Task task = createTaskInStack(stack, 0 /* userId */);

        // Add another display at top.
        sWm.mRoot.positionChildAt(WindowContainer.POSITION_TOP, createNewDisplay(),
                false /* includingParents */);

        // Move the task of {@code mDisplayContent} to top.
        stack.positionChildAt(WindowContainer.POSITION_TOP, task, true /* includingParents */);
        final int indexOfDisplayWithPinnedStack = sWm.mRoot.mChildren.indexOf(mDisplayContent);

        assertEquals("The testing DisplayContent should be moved to top with task",
                sWm.mRoot.getChildCount() - 1, indexOfDisplayWithPinnedStack);
    }
}