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

Commit b1fa0446 authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Improve algorithm for deciding which dim layers to animate.

We always want to animate non full screen dim layers, even if there
are full screen dimlayers registered. If there are full screen dim
layers we prefer the one that is currently dimming, otherwise any of
the full screen dim layers (since they are shared).

Bug: 24668543
Change-Id: Icfd5cca83fc371c641ceb2e7a7b62178535984b7
parent 374abe11
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -159,25 +159,33 @@ class DimBehindController {

    boolean animateDimLayers() {
        int fullScreen = -1;
        int fullScreenAndDimming = -1;
        boolean result = false;

        for (int i = mState.size() - 1; i >= 0; i--) {
            DimLayer.DimLayerUser dimLayerUser = mState.keyAt(i);
            if (dimLayerUser.isFullscreen()) {
            DimLayer.DimLayerUser user = mState.keyAt(i);
            if (user.isFullscreen()) {
                fullScreen = i;
                if (mState.valueAt(i).continueDimming) {
                    break;
                    fullScreenAndDimming = i;
                }
            } else {
                // We always want to animate the non fullscreen windows, they don't share their
                // dim layers.
                result |= animateDimLayers(user);
            }
        }
        if (fullScreen != -1) {
            return animateDimLayers(mState.keyAt(fullScreen));
        } else {
            boolean result = false;
            for (int i = mState.size() - 1; i >= 0; i--) {
                result |= animateDimLayers(mState.keyAt(i));
        // For the shared, full screen dim layer, we prefer the animation that is causing it to
        // appear.
        if (fullScreenAndDimming != -1) {
            result |= animateDimLayers(mState.keyAt(fullScreenAndDimming));
        } else if (fullScreen != -1) {
            // If there is no animation for the full screen dim layer to appear, we can use any of
            // the animators that will cause it to disappear.
            result |= animateDimLayers(mState.keyAt(fullScreen));
        }
        return result;
    }
    }

    private boolean animateDimLayers(DimLayer.DimLayerUser dimLayerUser) {
        DimBehindState state = mState.get(dimLayerUser);