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

Commit 7d95df49 authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Always check front stack on its current display

Previously checks for front stacks were looking among
stack on primary display only. This doesn't make any
sense for stacks on secondary screens, so let's always
check among other stacks on its current display.

Bug: 34862802
Test: Manual.
Change-Id: I29ee160d455719d75f4a5981a6ba9c60f3d90084
parent e4a2476e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2507,7 +2507,7 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL
                if (!next.hasBeenLaunched) {
                    next.hasBeenLaunched = true;
                } else  if (SHOW_APP_STARTING_PREVIEW && lastStack != null &&
                        mStackSupervisor.isFrontStack(lastStack)) {
                        mStackSupervisor.isFrontStackOnDisplay(lastStack)) {
                    next.showStartingWindow(null /* prev */, false /* newTask */,
                            false /* taskSwitch */);
                }
@@ -4354,7 +4354,7 @@ final class ActivityStack extends ConfigurationContainer implements StackWindowL
        // If we have a watcher, preflight the move before committing to it.  First check
        // for *other* available tasks, but if none are available, then try again allowing the
        // current task to be selected.
        if (mStackSupervisor.isFrontStack(this) && mService.mController != null) {
        if (mStackSupervisor.isFrontStackOnDisplay(this) && mService.mController != null) {
            ActivityRecord next = topRunningActivityLocked(null, taskId);
            if (next == null) {
                next = topRunningActivityLocked(null, 0);
+16 −13
Original line number Diff line number Diff line
@@ -624,11 +624,6 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        return stack == mFocusedStack;
    }

    /** The top most stack. */
    boolean isFrontStack(ActivityStack stack) {
        return isFrontOfStackList(stack, mHomeStack.mStacks);
    }

    /** The top most stack on its display. */
    boolean isFrontStackOnDisplay(ActivityStack stack) {
        return isFrontOfStackList(stack, stack.mActivityContainer.mActivityDisplay.mStacks);
@@ -1103,16 +1098,24 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        }

        // Look in other non-focused and non-home stacks.
        final ArrayList<ActivityStack> stacks = mHomeStack.mStacks;
        for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) {
            final ActivityStack stack = stacks.get(stackNdx);
            if (stack != focusedStack && isFrontStack(stack) && stack.isFocusable()) {
        mWindowManager.getDisplaysInFocusOrder(mTmpOrderedDisplayIds);

        for (int i = mTmpOrderedDisplayIds.size() - 1; i >= 0; --i) {
            final int displayId = mTmpOrderedDisplayIds.get(i);
            final List<ActivityStack> stacks = mActivityDisplays.get(displayId).mStacks;
            if (stacks == null) {
                continue;
            }
            for (int j = stacks.size() - 1; j >= 0; --j) {
                final ActivityStack stack = stacks.get(j);
                if (stack != focusedStack && isFrontStackOnDisplay(stack) && stack.isFocusable()) {
                    r = stack.topRunningActivityLocked();
                    if (r != null) {
                        return r;
                    }
                }
            }
        }
        return null;
    }

@@ -2676,7 +2679,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
        // In some cases the focused stack isn't the front stack. E.g. pinned stack.
        // Whenever we are moving the top activity from the front stack we want to make sure to move
        // the stack to the front.
        final boolean wasFront = isFrontStack(prevStack)
        final boolean wasFront = isFrontStackOnDisplay(prevStack)
                && (prevStack.topRunningActivityLocked() == r);

        if (stackId == DOCKED_STACK_ID && !task.isResizeable()) {
+1 −0
Original line number Diff line number Diff line
@@ -6146,6 +6146,7 @@ public class WindowManagerService extends IWindowManager.Stub
     * Get an array with display ids ordered by focus priority - last items should be given
     * focus first. Sparse array just maps position to displayId.
     */
    // TODO: Maintain display list in focus order in ActivityManager and remove this call.
    public void getDisplaysInFocusOrder(SparseIntArray displaysInFocusOrder) {
        synchronized(mWindowMap) {
            mRoot.getDisplaysInFocusOrder(displaysInFocusOrder);