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

Commit 6e5c7cb4 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Don't move multi-window stacks on orientation change."

parents 7d3cf592 4a02d813
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -340,6 +340,12 @@ class DisplayContent {
        }
        }
    }
    }


    static int deltaRotation(int oldRotation, int newRotation) {
        int delta = newRotation - oldRotation;
        if (delta < 0) delta += 4;
        return delta;
    }

    public void dump(String prefix, PrintWriter pw) {
    public void dump(String prefix, PrintWriter pw) {
        pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
        pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
        final String subPrefix = "  " + prefix;
        final String subPrefix = "  " + prefix;
+2 −8
Original line number Original line Diff line number Diff line
@@ -291,12 +291,6 @@ class ScreenRotationAnimation {
        return mSurfaceControl != null;
        return mSurfaceControl != null;
    }
    }


    static int deltaRotation(int oldRotation, int newRotation) {
        int delta = newRotation - oldRotation;
        if (delta < 0) delta += 4;
        return delta;
    }

    private void setSnapshotTransformInTransaction(Matrix matrix, float alpha) {
    private void setSnapshotTransformInTransaction(Matrix matrix, float alpha) {
        if (mSurfaceControl != null) {
        if (mSurfaceControl != null) {
            matrix.getValues(mTmpFloats);
            matrix.getValues(mTmpFloats);
@@ -352,7 +346,7 @@ class ScreenRotationAnimation {
        // Compute the transformation matrix that must be applied
        // Compute the transformation matrix that must be applied
        // to the snapshot to make it stay in the same original position
        // to the snapshot to make it stay in the same original position
        // with the current screen rotation.
        // with the current screen rotation.
        int delta = deltaRotation(rotation, Surface.ROTATION_0);
        int delta = DisplayContent.deltaRotation(rotation, Surface.ROTATION_0);
        createRotationMatrix(delta, mWidth, mHeight, mSnapshotInitialMatrix);
        createRotationMatrix(delta, mWidth, mHeight, mSnapshotInitialMatrix);


        if (DEBUG_STATE) Slog.v(TAG, "**** ROTATION: " + delta);
        if (DEBUG_STATE) Slog.v(TAG, "**** ROTATION: " + delta);
@@ -391,7 +385,7 @@ class ScreenRotationAnimation {
        boolean firstStart = false;
        boolean firstStart = false;


        // Figure out how the screen has moved from the original rotation.
        // Figure out how the screen has moved from the original rotation.
        int delta = deltaRotation(mCurRotation, mOriginalRotation);
        int delta = DisplayContent.deltaRotation(mCurRotation, mOriginalRotation);


        if (TWO_PHASE_ANIMATION && mFinishExitAnimation == null
        if (TWO_PHASE_ANIMATION && mFinishExitAnimation == null
                && (!dismissing || delta != Surface.ROTATION_0)) {
                && (!dismissing || delta != Surface.ROTATION_0)) {
+47 −4
Original line number Original line Diff line number Diff line
@@ -26,6 +26,8 @@ import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.EventLog;
import android.util.Slog;
import android.util.Slog;
import android.util.TypedValue;
import android.util.TypedValue;
import android.view.Display;
import android.view.Surface;


import com.android.server.EventLogTags;
import com.android.server.EventLogTags;


@@ -52,6 +54,8 @@ public class TaskStack {


    /** For comparison with DisplayContent bounds. */
    /** For comparison with DisplayContent bounds. */
    private Rect mTmpRect = new Rect();
    private Rect mTmpRect = new Rect();
    /** For handling display rotations. */
    private Rect mTmpRect2 = new Rect();


    /** Content limits relative to the DisplayContent this sits in. */
    /** Content limits relative to the DisplayContent this sits in. */
    private Rect mBounds = new Rect();
    private Rect mBounds = new Rect();
@@ -94,6 +98,9 @@ public class TaskStack {
    // the status bar.
    // the status bar.
    boolean mUnderStatusBar;
    boolean mUnderStatusBar;


    // Device rotation as of the last time {@link #mBounds} was set.
    int mRotation;

    TaskStack(WindowManagerService service, int stackId) {
    TaskStack(WindowManagerService service, int stackId) {
        mService = service;
        mService = service;
        mStackId = stackId;
        mStackId = stackId;
@@ -135,8 +142,10 @@ public class TaskStack {
    /** Set the stack bounds. Passing in null sets the bounds to fullscreen. */
    /** Set the stack bounds. Passing in null sets the bounds to fullscreen. */
    boolean setBounds(Rect bounds) {
    boolean setBounds(Rect bounds) {
        boolean oldFullscreen = mFullscreen;
        boolean oldFullscreen = mFullscreen;
        int rotation = Surface.ROTATION_0;
        if (mDisplayContent != null) {
        if (mDisplayContent != null) {
            mDisplayContent.getLogicalDisplayRect(mTmpRect);
            mDisplayContent.getLogicalDisplayRect(mTmpRect);
            rotation = mDisplayContent.getDisplayInfo().rotation;
            if (bounds == null) {
            if (bounds == null) {
                bounds = mTmpRect;
                bounds = mTmpRect;
                mFullscreen = true;
                mFullscreen = true;
@@ -147,10 +156,10 @@ public class TaskStack {
        }
        }


        if (bounds == null) {
        if (bounds == null) {
            // Can set to fullscreen if we don't have a display to get bounds from...
            // Can't set to fullscreen if we don't have a display to get bounds from...
            return false;
            return false;
        }
        }
        if (mBounds.equals(bounds) && oldFullscreen == mFullscreen) {
        if (mBounds.equals(bounds) && oldFullscreen == mFullscreen && mRotation == rotation) {
            return false;
            return false;
        }
        }


@@ -158,6 +167,7 @@ public class TaskStack {
        mAnimationBackgroundSurface.setBounds(bounds);
        mAnimationBackgroundSurface.setBounds(bounds);
        mBounds.set(bounds);
        mBounds.set(bounds);
        mUnderStatusBar = (mBounds.top == 0);
        mUnderStatusBar = (mBounds.top == 0);
        mRotation = rotation;
        updateOverrideConfiguration();
        updateOverrideConfiguration();
        return true;
        return true;
    }
    }
@@ -191,9 +201,42 @@ public class TaskStack {
    }
    }


    void updateDisplayInfo() {
    void updateDisplayInfo() {
        if (mFullscreen && mDisplayContent != null) {
        if (mFullscreen) {
            setBounds(null);
        } else if (mDisplayContent != null) {
            final int newRotation = mDisplayContent.getDisplayInfo().rotation;
            if (mRotation == newRotation) {
                return;
            }

            // Device rotation changed. We don't want the stack to move around on the screen when
            // this happens, so update the stack bounds so it stays in the same place.
            final int rotationDelta = DisplayContent.deltaRotation(mRotation, newRotation);
            mDisplayContent.getLogicalDisplayRect(mTmpRect);
            mDisplayContent.getLogicalDisplayRect(mTmpRect);
            setBounds(mTmpRect);
            switch (rotationDelta) {
                case Surface.ROTATION_0:
                    mTmpRect2.set(mBounds);
                    break;
                case Surface.ROTATION_90:
                    mTmpRect2.top = mTmpRect.bottom - mBounds.right;
                    mTmpRect2.left = mBounds.top;
                    mTmpRect2.right = mTmpRect2.left + mBounds.height();
                    mTmpRect2.bottom = mTmpRect2.top + mBounds.width();
                    break;
                case Surface.ROTATION_180:
                    mTmpRect2.top = mTmpRect.bottom - mBounds.bottom;
                    mTmpRect2.left = mTmpRect.right - mBounds.right;
                    mTmpRect2.right = mTmpRect2.left + mBounds.width();
                    mTmpRect2.bottom = mTmpRect2.top + mBounds.height();
                    break;
                case Surface.ROTATION_270:
                    mTmpRect2.top = mBounds.left;
                    mTmpRect2.left = mTmpRect.right - mBounds.bottom;
                    mTmpRect2.right = mTmpRect2.left + mBounds.height();
                    mTmpRect2.bottom = mTmpRect2.top + mBounds.width();
                    break;
            }
            setBounds(mTmpRect2);
        }
        }
    }
    }