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

Commit 89f5c1de authored by Evan Rosky's avatar Evan Rosky
Browse files

Update Task surface position when bounds are changed

While adjusting the task bounds for ime, the new bounds and
display bounds were getting updated, but not "applied" to the
container surface. Lower level (eg. AppWindowToken) positions
are calculated relative to the Task, so without actually moving
the task surface, the position on screen was wrong.

Bug: 120775895
Test: open 2 apps in vertical split, open IME on bottom app.
      With IME open and 2 apps split visible, rotate screen
      to landscape. Also added TaskTests#testBounds to
      verify that setting bounds updates surface position.

Change-Id: Ib7443310bd5009278766d52a84874451dd1e04ed
parent 59e3189d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta

        mRotation = rotation;

        updateSurfacePosition();
        return boundsChange;
    }

@@ -357,6 +358,7 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        } else {
            mOverrideDisplayedBounds.setEmpty();
        }
        updateSurfacePosition();
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.annotation.CallSuper;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.graphics.Point;
@@ -1330,6 +1331,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        mLastSurfacePosition.set(mTmpPos.x, mTmpPos.y);
    }

    @TestApi
    Point getLastSurfacePosition() {
        return mLastSurfacePosition;
    }

    /**
     * Displayed bounds specify where to display this container at. It differs from bounds during
     * certain operations (like animation or interactive dragging).
+17 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.graphics.Point;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;

import androidx.test.filters.SmallTest;
@@ -123,4 +125,19 @@ public class TaskTests extends WindowTestsBase {
        assertEquals(1, task2.positionInParent());
        assertTrue(task.mOnDisplayChangedCalled);
    }

    @Test
    public void testBounds() {
        final TaskStack stack1 = createTaskStackOnDisplay(mDisplayContent);
        final WindowTestUtils.TestTask task = WindowTestUtils.createTestTask(stack1);

        // Check that setting bounds also updates surface position
        Rect bounds = new Rect(10, 10, 100, 200);
        task.setBounds(bounds);
        assertEquals(new Point(bounds.left, bounds.top), task.getLastSurfacePosition());

        Rect dispBounds = new Rect(20, 30, 110, 220);
        task.setOverrideDisplayedBounds(dispBounds);
        assertEquals(new Point(dispBounds.left, dispBounds.top), task.getLastSurfacePosition());
    }
}