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

Commit 2cc92f55 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Don't relayout app contents when just changing app position

In WMS.resizeTasks we call task.resizeWindows() whenever the
task bounds changes which causes the app to do layout passes.
This isn't needed if we are just changing the position of the
task and not the size. This is currently causing unneeded churn
in the system and which leads to lag with the dragging operation.

Bug: 23901900
Change-Id: I339e31af3b657db6146dc1220bf5eb13e18b7876
parent c6c28731
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -40,6 +40,13 @@ class Task implements DimLayer.DimLayerUser {
     * when no window animation is driving it. */
    private static final int DEFAULT_DIM_DURATION = 200;

    // Return value from {@link setBounds} indicating no change was made to the Task bounds.
    static final int BOUNDS_CHANGE_NONE = 0;
    // Return value from {@link setBounds} indicating the position of the Task bounds changed.
    static final int BOUNDS_CHANGE_POSITION = 1;
    // Return value from {@link setBounds} indicating the size of the Task bounds changed.
    static final int BOUNDS_CHANGE_SIZE = 1 << 1;

    TaskStack mStack;
    final AppTokenList mAppTokens = new AppTokenList();
    final int mTaskId;
@@ -165,7 +172,7 @@ class Task implements DimLayer.DimLayerUser {
    }

    /** Set the task bounds. Passing in null sets the bounds to fullscreen. */
    boolean setBounds(Rect bounds, Configuration config) {
    int setBounds(Rect bounds, Configuration config) {
        if (config == null) {
            config = Configuration.EMPTY;
        }
@@ -190,7 +197,7 @@ class Task implements DimLayer.DimLayerUser {
                    // ensure bounds are entirely within the display rect
                    if (!bounds.intersect(mTmpRect)) {
                        // Can't set bounds outside the containing display...Sorry!
                        return false;
                        return BOUNDS_CHANGE_NONE;
                    }
                }
                mFullscreen = mTmpRect.equals(bounds);
@@ -199,17 +206,25 @@ class Task implements DimLayer.DimLayerUser {

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

        int boundsChange = BOUNDS_CHANGE_NONE;
        if (mBounds.left != bounds.left || mBounds.right != bounds.right) {
            boundsChange |= BOUNDS_CHANGE_POSITION;
        }
        if (mBounds.width() != bounds.width() || mBounds.height() != bounds.height()) {
            boundsChange |= BOUNDS_CHANGE_SIZE;
        }

        mBounds.set(bounds);
        mRotation = rotation;
        updateDimLayer();
        mOverrideConfig = mFullscreen ? Configuration.EMPTY : config;
        return true;
        return boundsChange;
    }

    void getBounds(Rect out) {
+6 −2
Original line number Diff line number Diff line
@@ -4612,8 +4612,12 @@ public class WindowManagerService extends IWindowManager.Stub
                throw new IllegalArgumentException("resizeTask: taskId " + taskId
                        + " not found.");
            }
            if (task.setBounds(bounds, configuration)) {
            final int boundsChanged = task.setBounds(bounds, configuration);
            if (boundsChanged != Task.BOUNDS_CHANGE_NONE) {
                if ((boundsChanged & Task.BOUNDS_CHANGE_SIZE) == Task.BOUNDS_CHANGE_SIZE) {
                    task.resizeWindows();
                }

                if (relayout) {
                    task.getDisplayContent().layoutNeeded = true;
                    mWindowPlacerLocked.performSurfacePlacement();