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

Commit d92e7eb2 authored by Robert Carr's avatar Robert Carr
Browse files

Restore old stack Z ordering promotion.

This is a more direct translation of what was in WindowLayersController.
We hoped that it wasn't necessary and that they were always in the correct
position in the WindowContainer hierarchy. However it seems there is no mechanism
to position them as such. It's not obvious for me how to resolve things from that angle
so I'm proposing reintroducing this logic.

Bug: 69553456
Bug: 70178829
Test: Manual. go/wm-smoke
Change-Id: I32ab03b1bcd6c498bf643c0f207d3f72286f258b
parent 5459651b
Loading
Loading
Loading
Loading
+33 −23
Original line number Diff line number Diff line
@@ -3493,37 +3493,47 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

        @Override
        void assignChildLayers(SurfaceControl.Transaction t) {
            int layer = 0;

            // We allow stacks to change visual order from the AM specified order due to
            // Z-boosting during animations. However we must take care to ensure TaskStacks
            // which are marked as alwaysOnTop remain that way.
            final int NORMAL_STACK_STATE = 0;
            final int SPLIT_SCREEN_STACK_STATE = 1;
            final int ASSISTANT_STACK_STATE = 2;
            final int BOOSTED_STATE = 3;
            final int ALWAYS_ON_TOP_STATE = 4;

            int layer = 0;
            for (int state = 0; state <= ALWAYS_ON_TOP_STATE; state++) {
                for (int i = 0; i < mChildren.size(); i++) {
                    final TaskStack s = mChildren.get(i);
                s.assignChildLayers();
                if (!s.needsZBoost() && !s.isAlwaysOnTop()) {
                    s.assignLayer(t, layer++);
                    layer++;
                    if (state == NORMAL_STACK_STATE && !s.inSplitScreenPrimaryWindowingMode() &&
                            !s.isActivityTypeAssistant() &&
                            !s.needsZBoost() && !s.isAlwaysOnTop()) {
                        s.assignLayer(t, layer);
                    } else if (state == SPLIT_SCREEN_STACK_STATE &&
                            s.inSplitScreenPrimaryWindowingMode()) {
                        s.assignLayer(t, layer);
                    } else if (state == ASSISTANT_STACK_STATE &&
                            s.isActivityTypeAssistant()) {
                        s.assignLayer(t, layer);
                    } else if (state == BOOSTED_STATE && s.needsZBoost()) {
                        s.assignLayer(t, layer);
                    } else if (state == ALWAYS_ON_TOP_STATE &&
                            s.isAlwaysOnTop()) {
                        s.assignLayer(t, layer);
                    }
                }
            for (int i = 0; i < mChildren.size(); i++) {
                final TaskStack s = mChildren.get(i);
                if (s.needsZBoost() && !s.isAlwaysOnTop()) {
                    s.assignLayer(t, layer++);
                // The appropriate place for App-Transitions to occur is right
                // above all other animations but still below things in the Picture-and-Picture
                // windowing mode.
                if (state == BOOSTED_STATE && mAppAnimationLayer != null) {
                    t.setLayer(mAppAnimationLayer, layer++);
                }
            }
            for (int i = 0; i < mChildren.size(); i++) {
                final TaskStack s = mChildren.get(i);
                if (s.isAlwaysOnTop()) {
                    s.assignLayer(t, layer++);
                }
                s.assignChildLayers(t);
            }

            // The appropriate place for App-Transitions to occur is right
            // above all other animations but still below things in the Picture-and-Picture
            // windowing mode.
            if (mAppAnimationLayer != null) {
                t.setLayer(mAppAnimationLayer, layer++);
            }
        }

        @Override
+9 −1
Original line number Diff line number Diff line
@@ -308,6 +308,8 @@ public class ZOrderingTests extends WindowTestsBase {

    @Test
    public void testStackLayers() throws Exception {
        final WindowState anyWindow1 =
                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "anyWindow");
        final WindowState pinnedStackWindow = createWindowOnStack(null, WINDOWING_MODE_PINNED,
                ACTIVITY_TYPE_STANDARD, TYPE_BASE_APPLICATION, mDisplayContent,
                "pinnedStackWindow");
@@ -317,10 +319,16 @@ public class ZOrderingTests extends WindowTestsBase {
        final WindowState assistantStackWindow = createWindowOnStack(null, WINDOWING_MODE_FULLSCREEN,
                ACTIVITY_TYPE_ASSISTANT, TYPE_BASE_APPLICATION,
                mDisplayContent, "assistantStackWindow");
        final WindowState anyWindow2 =
                createWindow(null, TYPE_BASE_APPLICATION, mDisplayContent, "anyWindow");

        mDisplayContent.assignChildLayers(mTransaction);

        assertWindowLayerGreaterThan(mTransaction, dockedStackWindow, mAppWindow);
        // We compare the split-screen windowing mode to two different normal windowing
        // mode windows added before and after it to ensure the correct Z ordering irrespective
        // of ordering in the child list.
        assertWindowLayerGreaterThan(mTransaction, dockedStackWindow, anyWindow1);
        assertWindowLayerGreaterThan(mTransaction, dockedStackWindow, anyWindow2);
        assertWindowLayerGreaterThan(mTransaction, assistantStackWindow, dockedStackWindow);
        assertWindowLayerGreaterThan(mTransaction, pinnedStackWindow, assistantStackWindow);
    }