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

Commit a1abd34f authored by mincheli's avatar mincheli
Browse files

Make the position of the mirror content the same as the real one

When the magnification scale is 1x, we can find that position of
the mirror content has a bias with the real content on the screen.
To fix it, we offset the the mirror view with the margin of
mirror surface view.

Bug: 148836275
Test: adb shell settings put secure window_magnification 1
Change-Id: I32e019f44183081819e06e056c080442458e5137
parent 784e8cac
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -324,8 +324,8 @@ public class WindowMagnificationController implements View.OnTouchListener, Surf
    private void setInitialStartBounds() {
        // Sets the initial frame area for the mirror and places it in the center of the display.
        int initSize = Math.min(mDisplaySize.x, mDisplaySize.y) / 2 + 2 * mMirrorSurfaceMargin;
        int initX = mDisplaySize.x / 2 - initSize / 2 - mMirrorSurfaceMargin;
        int initY = mDisplaySize.y / 2 - initSize / 2 - mMirrorSurfaceMargin;
        int initX = mDisplaySize.x / 2 - initSize / 2;
        int initY = mDisplaySize.y / 2 - initSize / 2;
        mMagnificationFrame.set(initX, initY, initX + initSize, initY + initSize);
    }

@@ -380,8 +380,9 @@ public class WindowMagnificationController implements View.OnTouchListener, Surf
    private void updateMirrorViewLayout() {
        WindowManager.LayoutParams params =
                (WindowManager.LayoutParams) mMirrorView.getLayoutParams();
        params.x = mMagnificationFrame.left;
        params.y = mMagnificationFrame.top;
        params.x = mMagnificationFrame.left - mMirrorSurfaceMargin;
        params.y = mMagnificationFrame.top - mMirrorSurfaceMargin;

        // Translates MirrorView position to make MirrorSurfaceView that is inside MirrorView
        // able to move close to the screen edges.
        final int maxMirrorViewX = mDisplaySize.x - mMirrorView.getWidth();