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

Commit bd0d9373 authored by Chong Zhang's avatar Chong Zhang
Browse files

Notify client when the window is moved because of a resize

We need to notify the client that the window has moved if a resize
results in a move without size change. This makes sure that relevent
info on client side (such as mAttachInfo.mWindowLeft/Top) gets updated
to the new frame. Things like View.getLocationOnScreen() may depend
on these to function.

Bug: 25565385
Change-Id: I5b9ded0b16243c14494f9a69257d56570ee8996d
parent 7e5445f2
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -285,6 +285,8 @@ class Task implements DimLayer.DimLayerUser {
        }
        if ((boundsChanged & BOUNDS_CHANGE_SIZE) == BOUNDS_CHANGE_SIZE) {
            resizeWindows();
        } else {
            moveWindows();
        }
        return true;
    }
@@ -463,13 +465,24 @@ class Task implements DimLayer.DimLayerUser {
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                if (!resizingWindows.contains(win)) {
                    if (DEBUG_RESIZE) Slog.d(TAG_WM, "setBounds: Resizing " + win);
                    if (DEBUG_RESIZE) Slog.d(TAG_WM, "resizeWindows: Resizing " + win);
                    resizingWindows.add(win);
                }
            }
        }
    }

    void moveWindows() {
        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                if (DEBUG_RESIZE) Slog.d(TAG_WM, "moveWindows: Moving " + win);
                win.mMovedByResize = true;
            }
        }
    }

    /**
     * Cancels any running app transitions associated with the task.
     */
+5 −3
Original line number Diff line number Diff line
@@ -417,6 +417,8 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    // the window is added and unset when this window reports its first draw.
    WindowState mReplacingWindow = null;

    // Whether this window is being moved via the resize API
    boolean mMovedByResize;
    /**
     * Wake lock for drawing.
     * Even though it's slightly more expensive to do so, we will use a separate wake lock
@@ -1208,9 +1210,9 @@ final class WindowState implements WindowManagerPolicy.WindowState {
     * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
     */
    boolean hasMoved() {
        return mHasSurface && mContentChanged && !mExiting && !mWinAnimator.mLastHidden
                && mService.okToDisplay() && (mFrame.top != mLastFrame.top
                        || mFrame.left != mLastFrame.left)
        return mHasSurface && (mContentChanged || mMovedByResize)
                && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
                && (mFrame.top != mLastFrame.top || mFrame.left != mLastFrame.left)
                && (mAttachedWindow == null || !mAttachedWindow.hasMoved());
    }

+1 −0
Original line number Diff line number Diff line
@@ -709,6 +709,7 @@ class WindowSurfacePlacer {

                //Slog.i(TAG_WM, "Window " + this + " clearing mContentChanged - done placing");
                w.mContentChanged = false;
                w.mMovedByResize = false;

                // Moved from updateWindowsAndWallpaperLocked().
                if (w.mHasSurface) {