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

Commit 5bf92046 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Use screen bounds instead of stable bounds in initial bounds calculation

Default initial bounds in the `DesktopModeLaunchParamsModifier`
should be calculated using `screenBounds` instead of `stableBounds`.

Flag: NONE (bug fix)
Fixes: 352693069
Test: atest WmTests:DesktopModeLaunchParamsModifierTests
Change-Id: Ia2b38b7ac5a810690edeeffc2404df239fc175f7
parent 88d75700
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -164,17 +164,16 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
    private void calculateAndCentreInitialBounds(Task task,
            LaunchParamsController.LaunchParams outParams) {
        // TODO(b/319819547): Account for app constraints so apps do not become letterboxed
        final Rect stableBounds = new Rect();
        task.getDisplayArea().getStableRect(stableBounds);
        final Rect screenBounds = task.getDisplayArea().getBounds();
        // The desired dimensions that a fully resizable window should take when initially entering
        // desktop mode. Calculated as a percentage of the available display area as defined by the
        // DESKTOP_MODE_INITIAL_BOUNDS_SCALE.
        final int desiredWidth = (int) (stableBounds.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
        final int desiredHeight = (int) (stableBounds.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
        final int desiredWidth = (int) (screenBounds.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
        final int desiredHeight = (int) (screenBounds.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
        outParams.mBounds.right = desiredWidth;
        outParams.mBounds.bottom = desiredHeight;
        outParams.mBounds.offset(stableBounds.centerX() - outParams.mBounds.centerX(),
                stableBounds.centerY() - outParams.mBounds.centerY());
        outParams.mBounds.offset(screenBounds.centerX() - outParams.mBounds.centerX(),
                screenBounds.centerY() - outParams.mBounds.centerY());
    }

    private void initLogBuilder(Task task, ActivityRecord activity) {
+2 −2
Original line number Diff line number Diff line
@@ -166,9 +166,9 @@ public class DesktopModeLaunchParamsModifierTests extends
                ACTIVITY_TYPE_STANDARD).setDisplay(display).build();

        final int desiredWidth =
                (int) (DISPLAY_STABLE_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
                (int) (DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
        final int desiredHeight =
                (int) (DISPLAY_STABLE_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
                (int) (DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
        assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task).calculate());
        assertEquals(desiredWidth, mResult.mBounds.width());
        assertEquals(desiredHeight, mResult.mBounds.height());