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

Commit 781fb487 authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge changes I4200d295,Ib80d5be3 into main

* changes:
  Do not mutate mDragStartTaskBounds during drag-resize
  Ensure the visual indicator is released after drag ends
parents 37d7dedf 22175211
Loading
Loading
Loading
Loading
+9 −24
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.wm.shell.desktopmode;

import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

import static com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler.FINAL_FREEFORM_SCALE;

@@ -86,7 +88,6 @@ public class DesktopModeVisualIndicator {
        mTaskSurface = taskSurface;
        mRootTdaOrganizer = taskDisplayAreaOrganizer;
        mCurrentType = IndicatorType.NO_INDICATOR;
        createView();
    }

    /**
@@ -127,34 +128,15 @@ public class DesktopModeVisualIndicator {
        mView = new View(mContext);
        final SurfaceControl.Builder builder = new SurfaceControl.Builder();
        mRootTdaOrganizer.attachToDisplayArea(mTaskInfo.displayId, builder);
        String description;
        switch (mCurrentType) {
            case TO_DESKTOP_INDICATOR:
                description = "Desktop indicator";
                break;
            case TO_FULLSCREEN_INDICATOR:
                description = "Fullscreen indicator";
                break;
            case TO_SPLIT_LEFT_INDICATOR:
                description = "Split Left indicator";
                break;
            case TO_SPLIT_RIGHT_INDICATOR:
                description = "Split Right indicator";
                break;
            default:
                description = "Invalid indicator";
                break;
        }
        mLeash = builder
                .setName(description)
                .setName("Desktop Mode Visual Indicator")
                .setContainerLayer()
                .build();
        t.show(mLeash);
        final WindowManager.LayoutParams lp =
                new WindowManager.LayoutParams(screenWidth, screenHeight,
                        WindowManager.LayoutParams.TYPE_APPLICATION,
                        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT);
        lp.setTitle(description + " for Task=" + mTaskInfo.taskId);
                new WindowManager.LayoutParams(screenWidth, screenHeight, TYPE_APPLICATION,
                        FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT);
        lp.setTitle("Desktop Mode Visual Indicator");
        lp.setTrustedOverlay();
        final WindowlessWindowManager windowManager = new WindowlessWindowManager(
                mTaskInfo.configuration, mLeash,
@@ -201,6 +183,9 @@ public class DesktopModeVisualIndicator {
     */
    private void transitionIndicator(IndicatorType newType) {
        if (mCurrentType == newType) return;
        if (mView == null) {
            createView();
        }
        if (mCurrentType == IndicatorType.NO_INDICATOR) {
            fadeInIndicator(newType);
        } else if (newType == IndicatorType.NO_INDICATOR) {
+7 −2
Original line number Diff line number Diff line
@@ -919,22 +919,27 @@ class DesktopTasksController(
        }
        if (taskBounds.top <= transitionAreaHeight) {
            moveToFullscreenWithAnimation(taskInfo, position)
            return
        }
        if (inputCoordinate.x <= transitionAreaWidth) {
            releaseVisualIndicator()
            var wct = WindowContainerTransaction()
            val wct = WindowContainerTransaction()
            addMoveToSplitChanges(wct, taskInfo)
            splitScreenController.requestEnterSplitSelect(taskInfo, wct,
                SPLIT_POSITION_TOP_OR_LEFT, taskBounds)
            return
        }
        if (inputCoordinate.x >= (displayController.getDisplayLayout(taskInfo.displayId)?.width()
            ?.minus(transitionAreaWidth) ?: return)) {
            releaseVisualIndicator()
            var wct = WindowContainerTransaction()
            val wct = WindowContainerTransaction()
            addMoveToSplitChanges(wct, taskInfo)
            splitScreenController.requestEnterSplitSelect(taskInfo, wct,
                SPLIT_POSITION_BOTTOM_OR_RIGHT, taskBounds)
            return
        }
        // A freeform drag-move ended, remove the indicator immediately.
        releaseVisualIndicator()
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -353,6 +353,7 @@ class DragResizeInputListener implements AutoCloseable {
        private boolean mShouldHandleEvents;
        private int mLastCursorType = PointerIcon.TYPE_DEFAULT;
        private Rect mDragStartTaskBounds;
        private final Rect mTmpRect = new Rect();

        private TaskResizeInputEventReceiver(
                InputChannel inputChannel, Handler handler, Choreographer choreographer) {
@@ -477,14 +478,15 @@ class DragResizeInputListener implements AutoCloseable {
        }

        private void updateInputSinkRegionForDrag(Rect taskBounds) {
            mTmpRect.set(taskBounds);
            final DisplayLayout layout = mDisplayController.getDisplayLayout(mDisplayId);
            final Region dragTouchRegion = new Region(-taskBounds.left,
                    -taskBounds.top,
                    -taskBounds.left + layout.width(),
                    -taskBounds.top + layout.height());
            // Remove the localized task bounds from the touch region.
            taskBounds.offsetTo(0, 0);
            dragTouchRegion.op(taskBounds, Region.Op.DIFFERENCE);
            mTmpRect.offsetTo(0, 0);
            dragTouchRegion.op(mTmpRect, Region.Op.DIFFERENCE);
            updateSinkInputChannel(dragTouchRegion);
        }