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

Commit 0ba68c38 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "Use fullscreen sized buffer for drag resizing"

parents ba630dba 09b21efb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ class DisplayContent {
            for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
                final Task task = tasks.get(taskNdx);
                task.getBounds(mTmpRect);
                if (mTmpRect.contains(x, y)) {
                if (task.inFreeformWorkspace() && mTmpRect.contains(x, y)) {
                    return task.mTaskId;
                }
            }
@@ -299,7 +299,7 @@ class DisplayContent {
                 * (For freeform focused task, the below logic will first remove the enlarged
                 * area, then add back the inner area.)
                 */
                final boolean isFreeformed = win.inFreeformWorkspace();
                final boolean isFreeformed = task.inFreeformWorkspace();
                if (task != focusedTask || isFreeformed) {
                    mTmpRect.set(win.mVisibleFrame);
                    mTmpRect.intersect(win.mVisibleInsets);
+4 −0
Original line number Diff line number Diff line
@@ -426,6 +426,10 @@ class Task implements DimLayer.DimLayerUser {
        return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers;
    }

    boolean inFreeformWorkspace() {
        return mStack != null && mStack.mStackId == FREEFORM_WORKSPACE_STACK_ID;
    }

    @Override
    public boolean isFullscreen() {
        return mFullscreen;
+13 −2
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ class TaskPositioner implements DimLayer.DimLayerUser {

    private int mTaskId;
    private TaskStack mStack;
    private boolean mResizing;
    private final Rect mWindowOriginalBounds = new Rect();
    private final Rect mWindowDragBounds = new Rect();
    private float mStartDragX;
@@ -131,8 +132,8 @@ class TaskPositioner implements DimLayer.DimLayerUser {
                            notifyMoveLocked(newX, newY);
                        }
                        try {
                            mService.mActivityManager.resizeTask(mTaskId, mWindowDragBounds,
                                    true /* resizedByUser */);
                            mService.mActivityManager.resizeTask(
                                    mTaskId, mWindowDragBounds, true /* resizedByUser */);
                        } catch(RemoteException e) {}
                    } break;

@@ -152,6 +153,11 @@ class TaskPositioner implements DimLayer.DimLayerUser {
                }

                if (endDrag) {
                    mResizing = false;
                    try {
                        mService.mActivityManager.resizeTask(
                                mTaskId, mWindowDragBounds, true /* resizedByUser */);
                    } catch(RemoteException e) {}
                    // Post back to WM to handle clean-ups. We still need the input
                    // event handler for the last finishInputEvent()!
                    mService.mH.sendEmptyMessage(H.FINISH_TASK_POSITIONING);
@@ -280,6 +286,10 @@ class TaskPositioner implements DimLayer.DimLayerUser {
        mService.resumeRotationLocked();
    }

    boolean isTaskResizing(final Task task) {
        return mResizing && task != null && mTaskId == task.mTaskId;
    }

    void startDragLocked(WindowState win, boolean resize, float startX, float startY) {
        if (DEBUG_TASK_POSITIONING) {
            Slog.d(TAG, "startDragLocked: win=" + win + ", resize=" + resize
@@ -300,6 +310,7 @@ class TaskPositioner implements DimLayer.DimLayerUser {
            if (startY > visibleFrame.bottom) {
                mCtrlType |= CTRL_BOTTOM;
            }
            mResizing = true;
        }

        final Task task = win.getTask();
+14 −5
Original line number Diff line number Diff line
@@ -557,7 +557,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {

        final Task task = mAppToken != null ? getTask() : null;
        final boolean nonFullscreenTask = task != null && !task.isFullscreen();
        final boolean freeformWorkspace = inFreeformWorkspace();
        final boolean freeformWorkspace = task != null && task.inFreeformWorkspace();
        if (nonFullscreenTask) {
            task.getBounds(mContainingFrame);
            final WindowState imeWin = mService.mInputMethodWindow;
@@ -897,6 +897,11 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        return stack == null ? mDisplayContent : stack.getDisplayContent();
    }

    public DisplayInfo getDisplayInfo() {
        final DisplayContent displayContent = getDisplayContent();
        return displayContent != null ? displayContent.getDisplayInfo() : null;
    }

    public int getDisplayId() {
        final DisplayContent displayContent = getDisplayContent();
        if (displayContent == null) {
@@ -935,7 +940,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        if (task != null) {
            task.getBounds(bounds);
            if (forTouch == BOUNDS_FOR_TOUCH) {
                if (inFreeformWorkspace()) {
                if (task.inFreeformWorkspace()) {
                    final int delta = calculatePixelFromDp(RESIZE_HANDLE_WIDTH_IN_DP);
                    bounds.inset(-delta, -delta);
                }
@@ -1668,9 +1673,13 @@ final class WindowState implements WindowManagerPolicy.WindowState {
    }

    boolean inFreeformWorkspace() {
        final Task task = getTask();
        return task != null && task.mStack != null &&
                task.mStack.mStackId == FREEFORM_WORKSPACE_STACK_ID;
        final Task task = mAppToken != null ? getTask() : null;
        return task != null && task.inFreeformWorkspace();
    }

    boolean isDragResizing() {
        final Task task = mAppToken != null ? getTask() : null;
        return mService.mTaskPositioner != null && mService.mTaskPositioner.isTaskResizing(task);
    }

    private int calculatePixelFromDp(int dp) {
+31 −7
Original line number Diff line number Diff line
@@ -803,10 +803,19 @@ class WindowStateAnimator {
                // size.
                width = w.mRequestedWidth;
                height = w.mRequestedHeight;
            } else {
                // When we're doing a drag-resizing, request a surface that's fullscreen size,
                // so that we don't need to reallocate during the process. This also prevents
                // buffer drops due to size mismatch.
                final DisplayInfo displayInfo = w.getDisplayInfo();
                if (displayInfo != null && w.isDragResizing()) {
                    width = displayInfo.logicalWidth;
                    height = displayInfo.logicalHeight;
                } else {
                    width = w.mCompatFrame.width();
                    height = w.mCompatFrame.height();
                }
            }

            // Something is wrong and SurfaceFlinger will not like this,
            // try to revert to sane values
@@ -1315,9 +1324,15 @@ class WindowStateAnimator {

        final boolean fullscreen = w.isFullscreen(displayInfo.appWidth, displayInfo.appHeight);
        final Rect clipRect = mTmpClipRect;
        if (w.isDragResizing()) {
            // When we're doing a drag-resizing, the surface is set up to cover full screen.
            // Set the clip rect to be the same size so that we don't get any scaling.
            clipRect.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
        } else {
            // We use the clip rect as provided by the tranformation for non-fullscreen windows to
            // avoid premature clipping with the system decor rect.
            clipRect.set((mHasClipRect && !fullscreen) ? mClipRect : w.mSystemDecorRect);
        }

        // Expand the clip rect for surface insets.
        final WindowManager.LayoutParams attrs = w.mAttrs;
@@ -1390,10 +1405,19 @@ class WindowStateAnimator {
            // size.
            width  = w.mRequestedWidth;
            height = w.mRequestedHeight;
        } else {
            // When we're doing a drag-resizing, request a surface that's fullscreen size,
            // so that we don't need to reallocate during the process. This also prevents
            // buffer drops due to size mismatch.
            final DisplayInfo displayInfo = w.getDisplayInfo();
            if (displayInfo != null && w.isDragResizing()) {
                width = displayInfo.logicalWidth;
                height = displayInfo.logicalHeight;
            } else {
                width = w.mCompatFrame.width();
                height = w.mCompatFrame.height();
            }
        }

        // Something is wrong and SurfaceFlinger will not like this,
        // try to revert to sane values
Loading