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

Commit 51e4c2f2 authored by chaviw's avatar chaviw
Browse files

Move DimLayer to Root if translucent window and not multi-window

When the first window in a Task opens, the Task will animate to enter
instead of the app with the introduction of hierarchal animations. This
causes problems if the first window is translucent and has a dim since
the dim layer will animate with the Task instead of fading in.

To prevent that, we can move the dim layer to a higher up level in the
hierarchy, but still maintain the relative Z order. We still place the
dim at the Task level if the Task is non translucent or if the Task is
in multi-window mode. We find the root task and check if it's translucent.
If so, it will find the Dimmer object for the next level up in the
hierarchy and create the dim layer at that level instead of the Task.
If the Task is not translucent, we add the dimmer to the Task level.

Since the dim layer is at the display level, translucent Tasks don't
behave correctly when swiping to recents. When the dim layer was
parented to the Task, the dim layer would animate with the Task when
swiping up to recents. In this change, the dim layer will fade out if
placed on the display level when swiping to go to recents.

Test: Open assistant and see dim layer fade in
Test: Open translucent app with dim layer. Swipe to recents
Fixes: 148938447
Change-Id: I6e275b778da4cb7aeda3b3483a14f5f9d2796e44
parent e234ca4a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -253,6 +253,12 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
            super.prepareSurfaces();
            getBounds(mTmpDimBoundsRect);

            // If SystemUI is dragging for recents, we want to reset the dim state so any dim layer
            // on the display level fades out.
            if (forAllTasks(task -> !task.canAffectSystemUiFlags())) {
                mDimmer.resetDimStates();
            }

            if (mDimmer.updateDims(getPendingTransaction(), mTmpDimBoundsRect)) {
                scheduleAnimation();
            }
+15 −0
Original line number Diff line number Diff line
@@ -3347,6 +3347,21 @@ class Task extends WindowContainer<WindowContainer> {

    @Override
    Dimmer getDimmer() {
        // If the window is in multi-window mode, we want to dim at the Task level to ensure the dim
        // bounds match the area the app lives in
        if (inMultiWindowMode()) {
            return mDimmer;
        }

        // If we're not at the root task level, we want to keep traversing through the parents to
        // find the root.
        // Once at the root task level, we want to check {@link #isTranslucent(ActivityRecord)}.
        // If true, we want to get the Dimmer from the level above since we don't want to animate
        // the dim with the Task.
        if (!isRootTask() || isTranslucent(null)) {
            return super.getDimmer();
        }

        return mDimmer;
    }