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

Commit 57831b51 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Move display order of focused stack to top when updating focus

Now focused stack depends on the order of display, so if a stack
is expected to be focused, its display should also move to top.

Bug: 111818977
Test: atest CtsActivityManagerDeviceTestCases:ActivityManagerMultiDisplayTests
Test: atest FrameworksServicesTests:ActivityStackSupervisorTests
Change-Id: I38e0aa4a78712561ab796b6522b733421286b7d9
parent 12563327
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -153,15 +153,19 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        onStackOrderChanged();
    }

    void positionChildAtTop(ActivityStack stack) {
        positionChildAt(stack, mStacks.size());
    void positionChildAtTop(ActivityStack stack, boolean includingParents) {
        positionChildAt(stack, mStacks.size(), includingParents);
    }

    void positionChildAtBottom(ActivityStack stack) {
        positionChildAt(stack, 0);
        positionChildAt(stack, 0, false /* includingParents */);
    }

    private void positionChildAt(ActivityStack stack, int position) {
        positionChildAt(stack, position, false /* includingParents */);
    }

    private void positionChildAt(ActivityStack stack, int position, boolean includingParents) {
        // TODO: Keep in sync with WindowContainer.positionChildAt(), once we change that to adjust
        //       the position internally, also update the logic here
        mStacks.remove(stack);
@@ -173,7 +177,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        // we don't have to call WindowContainerController#positionChildAt() here.
        if (stack.getWindowContainerController() != null) {
            mWindowContainerController.positionChildAt(stack.getWindowContainerController(),
                    insertPosition);
                    insertPosition, includingParents);
        }
        onStackOrderChanged();
    }
+3 −3
Original line number Diff line number Diff line
@@ -516,7 +516,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            // Since always on top is only on when the stack is freeform or pinned, the state
            // can be toggled when the windowing mode changes. We must make sure the stack is
            // placed properly when always on top state changes.
            display.positionChildAtTop(this);
            display.positionChildAtTop(this, false /* includingParents */);
        }
    }

@@ -1056,7 +1056,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            mStackSupervisor.moveHomeStackToFront(reason + " returnToHome");
        }

        display.positionChildAtTop(this);
        display.positionChildAtTop(this, true /* includingParents */);
        mStackSupervisor.setFocusStackUnchecked(reason, this);
        if (task != null) {
            // This also moves the entire hierarchy branch to top, including parents
@@ -5319,7 +5319,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        // always on top windows. Since the position the stack should be inserted into is calculated
        // properly in {@link ActivityDisplay#getTopInsertPosition()} in both cases, we can just
        // request that the stack is put at top here.
        display.positionChildAtTop(this);
        display.positionChildAtTop(this, false /* includingParents */);
    }

    void moveToFrontAndResumeStateIfNeeded(ActivityRecord r, boolean moveToFront, boolean setResume,
+2 −2
Original line number Diff line number Diff line
@@ -1931,8 +1931,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        getParent().positionChildAt(position, this, includingParents);
    }

    void positionStackAt(int position, TaskStack child) {
        mTaskStackContainers.positionChildAt(position, child, false /* includingParents */);
    void positionStackAt(int position, TaskStack child, boolean includingParents) {
        mTaskStackContainers.positionChildAt(position, child, includingParents);
        layoutAndAssignWindowLayersIfNeeded();
    }

+3 −2
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ public class DisplayWindowController
    /**
     * Positions the task stack at the given position in the task stack container.
     */
    public void positionChildAt(StackWindowController child, int position) {
    public void positionChildAt(StackWindowController child, int position,
            boolean includingParents) {
        synchronized (mWindowMap) {
            if (DEBUG_STACK) Slog.i(TAG_WM, "positionTaskStackAt: positioning stack=" + child
                    + " at " + position);
@@ -90,7 +91,7 @@ public class DisplayWindowController
                        "positionTaskStackAt: could not find stack=" + this);
                return;
            }
            mContainer.positionStackAt(position, child.mContainer);
            mContainer.positionStackAt(position, child.mContainer, includingParents);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -751,7 +751,7 @@ public class TaskStack extends WindowContainer<Task> implements
            // be inserted into is calculated properly in
            // {@link DisplayContent#findPositionForStack()} in both cases, we can just request that
            // the stack is put at top here.
            mDisplayContent.positionStackAt(POSITION_TOP, this);
            mDisplayContent.positionStackAt(POSITION_TOP, this, false /* includingParents */);
        }
    }

Loading