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

Commit 3c62c008 authored by Tiger's avatar Tiger
Browse files

Make sure to update last frames after handling moving and resizing

Previously, the last frames won't be updated if the window frame is only
moved but not resized. That made the server think the window is in a
moving state and might play redundant moving animations with it.

This CL makes sure the server updates the last frames after moving and
resizing windows are handled.

Fix: 299660994
Test: Move a floating window and see if the frame and the last frame are
      the same in the result of `adb shell dumpsys window all`.
Change-Id: I103ad921e783c01135ddca49c277dd77ef7b5680
parent fb34923b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -937,6 +937,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                // so we still request the window to resize if the current frame is empty.
                if (!w.getFrame().isEmpty()) {
                    w.updateLastFrames();
                    mWmService.mFrameChangingWindows.remove(w);
                }
                w.onResizeHandled();
            }
+12 −0
Original line number Diff line number Diff line
@@ -847,6 +847,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        }

        handleResizingWindows();
        clearFrameChangingWindows();

        if (mWmService.mDisplayFrozen) {
            ProtoLog.v(WM_DEBUG_ORIENTATION,
@@ -1014,6 +1015,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        }
    }

    /**
     * Clears frame changing windows after handling moving and resizing windows.
     */
    private void clearFrameChangingWindows() {
        final ArrayList<WindowState> frameChangingWindows = mWmService.mFrameChangingWindows;
        for (int i = frameChangingWindows.size() - 1; i >= 0; i--) {
            frameChangingWindows.get(i).updateLastFrames();
        }
        frameChangingWindows.clear();
    }

    /**
     * @param w        WindowState this method is applied to.
     * @param obscured True if there is a window on top of this obscuring the display.
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ public class WindowFrames {
    final Rect mFrame = new Rect();

    /**
     * The last real frame that was reported to the client.
     * The frame used to check if mFrame is changed, e.g., moved or resized.  It will be committed
     * after handling the moving or resizing windows.
     */
    final Rect mLastFrame = new Rect();

+6 −0
Original line number Diff line number Diff line
@@ -587,6 +587,12 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    final ArrayList<WindowState> mResizingWindows = new ArrayList<>();

    /**
     * Windows that their frames are being changed.  Used so we can clear the frame-changing states
     * after handling the moved or resized windows.
     */
    final ArrayList<WindowState> mFrameChangingWindows = new ArrayList<>();

    /**
     * Mapping of displayId to {@link DisplayImePolicy}.
     * Note that this can be accessed without holding the lock.
+5 −4
Original line number Diff line number Diff line
@@ -1346,6 +1346,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            windowFrames.setContentChanged(true);
        }

        if (!windowFrames.mFrame.equals(windowFrames.mLastFrame)
                || !windowFrames.mRelFrame.equals(windowFrames.mLastRelFrame)) {
            mWmService.mFrameChangingWindows.add(this);
        }

        if (mAttrs.type == TYPE_DOCK_DIVIDER) {
            if (!windowFrames.mFrame.equals(windowFrames.mLastFrame)) {
                mMovedByResize = true;
@@ -3716,10 +3721,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mDragResizingChangeReported = true;
        mWindowFrames.clearReportResizeHints();

        // We update mLastFrame always rather than in the conditional with the last inset
        // variables, because mFrameSizeChanged only tracks the width and height changing.
        updateLastFrames();

        final int prevRotation = mLastReportedConfiguration
                .getMergedConfiguration().windowConfiguration.getRotation();
        fillClientWindowFramesAndConfiguration(mClientWindowFrames, mLastReportedConfiguration,