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

Commit f18f5bf7 authored by Ivan Tkachenko's avatar Ivan Tkachenko
Browse files

Fix Desktop Windowing focus if clicked in Taskbar

* Added `hasOrderChanges` to `Transition` to make a shallow check if
  there was a reorder change.
* Updated `ActivityStarter.handleStartResult` to not abort
  `START_DELIVERED_TO_TOP` result when has reorder changes.

Bug: 308995974
Test: manual, atest TransitionTests
Flag: none
Change-Id: Ia295ead19109126a6406ab9de4427f4270341ca6
parent c8ce1cc5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1567,6 +1567,7 @@ class ActivityStarter {
                // An activity has changed order/visibility or the task is occluded by a transient
                // activity, so this isn't just deliver-to-top
                && mMovedToTopActivity == null
                && !transitionController.hasOrderChanges()
                && !transitionController.isTransientHide(startedActivityRootTask)) {
            // We just delivered to top, so there isn't an actual transition here.
            if (!forceTransientTransition) {
+21 −0
Original line number Diff line number Diff line
@@ -1755,6 +1755,27 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }
    }

    /**
     * Checks if the transition contains order changes.
     *
     * This is a shallow check that doesn't account for collection in parallel, unlike
     * {@code collectOrderChanges}
     */
    boolean hasOrderChanges() {
        ArrayList<Task> onTopTasks = new ArrayList<>();
        // Iterate over target displays to get up to date on top tasks.
        // Cannot use `mOnTopTasksAtReady` as it's not populated before the `applyReady` is called.
        for (DisplayContent dc : mTargetDisplays) {
            addOnTopTasks(dc, onTopTasks);
        }
        for (Task task : onTopTasks) {
            if (!mOnTopTasksStart.contains(task)) {
                return true;
            }
        }
        return false;
    }

    /**
     * Collect tasks which moved-to-top as part of this transition. This also updates the
     * controller's latest-reported when relevant.
+6 −0
Original line number Diff line number Diff line
@@ -792,6 +792,12 @@ class TransitionController {
        mCollectingTransition.recordTaskOrder(wc);
    }

    /** @see Transition#hasOrderChanges */
    boolean hasOrderChanges() {
        if (mCollectingTransition == null) return false;
        return mCollectingTransition.hasOrderChanges();
    }

    /**
     * Collects the window containers which need to be synced with the changing display area into
     * the current collecting transition.
+3 −0
Original line number Diff line number Diff line
@@ -2015,6 +2015,9 @@ public class TransitionTests extends WindowTestsBase {
        transition.collect(leafTaskA);
        rootTaskA.moveToFront("test", leafTaskA);

        // Test has order changes, a shallow check of order changes
        assertTrue(transition.hasOrderChanges());

        // All the tasks were already visible, so there shouldn't be any changes
        ArrayList<Transition.ChangeInfo> targets = Transition.calculateTargets(
                participants, changes);