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

Commit e909802b authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix flicker and other weirdness

- When moving tasks to/from fullscreen <-> docked stack, don't
replace windows, but preserve them.
- Fix a bug where we didn't called prepareFreezingBounds which
caused the clip rect to be set to (0, 0, 0, 0) for one frame

Bug: 26070457
Change-Id: I439c9b6612367babfbf31899022209eeee3e1be1
parent 8e7fffd1
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -560,11 +560,13 @@ public class ActivityManager {
        }

        /**
         * Returns true if the windows of tasks being moved to this stack should be preserved so
         * there isn't a display gap.
         * Returns true if the windows of tasks being moved to the target stack from the source
         * stack should be replaced, meaning that window manager will keep the old window around
         * until the new is ready.
         */
        public static boolean preserveWindowOnTaskMove(int stackId) {
            return stackId == FULLSCREEN_WORKSPACE_STACK_ID || stackId == DOCKED_STACK_ID;
        public static boolean replaceWindowsOnTaskMove(int sourceStackId, int targetStackId) {
            return sourceStackId == FREEFORM_WORKSPACE_STACK_ID
                    || targetStackId == FREEFORM_WORKSPACE_STACK_ID;
        }

        /**
+10 −5
Original line number Diff line number Diff line
@@ -2240,8 +2240,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }

        final ActivityRecord topActivity = task.getTopActivity();
        final int sourceStackId = task.stack != null ? task.stack.mStackId : INVALID_STACK_ID;
        final boolean mightReplaceWindow =
                StackId.preserveWindowOnTaskMove(stackId) && topActivity != null;
                StackId.replaceWindowsOnTaskMove(sourceStackId, stackId) && topActivity != null;
        if (mightReplaceWindow) {
            // We are about to relaunch the activity because its configuration changed due to
            // being maximized, i.e. size change. The activity will first remove the old window
@@ -2263,15 +2264,19 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }

        boolean kept = true;

        // We might trigger a configuration change. Save the current task bounds for freezing.
        mWindowManager.prepareFreezingTaskBounds(stack.mStackId);

        // Make sure the task has the appropriate bounds/size for the stack it is in.
        if (stackId == FULLSCREEN_WORKSPACE_STACK_ID && task.mBounds != null) {
            kept = resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
            kept = resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM, !mightReplaceWindow);
        } else if (stackId == FREEFORM_WORKSPACE_STACK_ID
                && task.mBounds == null && task.mLastNonFullscreenBounds != null) {
            kept = resizeTaskLocked(task, task.mLastNonFullscreenBounds,
                    RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
                    RESIZE_MODE_SYSTEM, !mightReplaceWindow);
        } else if (stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID) {
            kept = resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM, !PRESERVE_WINDOWS);
            kept = resizeTaskLocked(task, stack.mBounds, RESIZE_MODE_SYSTEM, !mightReplaceWindow);
        }

        if (mightReplaceWindow) {
@@ -2283,7 +2288,7 @@ public final class ActivityStackSupervisor implements DisplayListener {

        // The task might have already been running and its visibility needs to be synchronized with
        // the visibility of the stack / windows.
        ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
        ensureActivitiesVisibleLocked(null, 0, !mightReplaceWindow);
        resumeFocusedStackTopActivityLocked();

        showNonResizeableDockToastIfNeeded(task, preferredLaunchStackId, stackId);