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

Commit c1b87626 authored by Jorge Gil's avatar Jorge Gil
Browse files

Do not set a disallowedAreaForEndBounds for caption window decors

The disallowedAreaForEndBounds is meant to be used when another
component will handle a drag move end in that region (such as a
transition to fullscreen in desktop mode) and the positioner does
not need to finalize the bounds change with a WCT.
Caption window decorations does not have another component handling
the task moves within the status bar region, so the disallowed
area should not be set so that the positioner can finalize the bounds
correctly.

Bug: 281129969
Test: drag-move a task in freeform on a pixel into the status bar
area, release and confirm the task surface is not stuck behind the
status bar.

Change-Id: Ic7aa895c7b3d71619a8eb03f432e15f37d469f27
parent ec160013
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;

import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
import android.os.IBinder;
import android.util.SparseArray;
@@ -186,8 +185,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                        mSyncQueue);
        mWindowDecorByTaskId.put(taskInfo.taskId, windowDecoration);

        final DragPositioningCallback dragPositioningCallback = createDragPositioningCallback(
                windowDecoration, taskInfo);
        final DragPositioningCallback dragPositioningCallback =
                new FluidResizeTaskPositioner(mTaskOrganizer, windowDecoration, mDisplayController,
                        null /* disallowedAreaForEndBounds */);
        final CaptionTouchEventListener touchEventListener =
                new CaptionTouchEventListener(taskInfo, dragPositioningCallback);
        windowDecoration.setCaptionListeners(touchEventListener, touchEventListener);
@@ -198,17 +198,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
        setupCaptionColor(taskInfo, windowDecoration);
    }

    private FluidResizeTaskPositioner createDragPositioningCallback(
            CaptionWindowDecoration windowDecoration, RunningTaskInfo taskInfo) {
        final int screenWidth = mDisplayController.getDisplayLayout(taskInfo.displayId).width();
        final int statusBarHeight = mDisplayController.getDisplayLayout(taskInfo.displayId)
                .stableInsets().top;
        final Rect disallowedAreaForEndBounds = new Rect(0, 0, screenWidth,
                statusBarHeight);
        return new FluidResizeTaskPositioner(mTaskOrganizer, windowDecoration,
                    mDisplayController, disallowedAreaForEndBounds);
    }

    private class CaptionTouchEventListener implements
            View.OnClickListener, View.OnTouchListener, DragDetector.MotionEventHandler {

+6 −4
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.graphics.Rect;
import android.view.SurfaceControl;
import android.window.WindowContainerTransaction;

import androidx.annotation.Nullable;

import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.DisplayController;

@@ -42,24 +44,24 @@ class FluidResizeTaskPositioner implements DragPositioningCallback {
    private final Rect mRepositionTaskBounds = new Rect();
    // If a task move (not resize) finishes in this region, the positioner will not attempt to
    // finalize the bounds there using WCT#setBounds
    private final Rect mDisallowedAreaForEndBounds = new Rect();
    private final Rect mDisallowedAreaForEndBounds;
    private boolean mHasDragResized;
    private int mCtrlType;

    FluidResizeTaskPositioner(ShellTaskOrganizer taskOrganizer, WindowDecoration windowDecoration,
            DisplayController displayController, Rect disallowedAreaForEndBounds) {
            DisplayController displayController, @Nullable Rect disallowedAreaForEndBounds) {
        this(taskOrganizer, windowDecoration, displayController, disallowedAreaForEndBounds,
                dragStartListener -> {}, SurfaceControl.Transaction::new);
    }

    FluidResizeTaskPositioner(ShellTaskOrganizer taskOrganizer, WindowDecoration windowDecoration,
            DisplayController displayController, Rect disallowedAreaForEndBounds,
            DisplayController displayController, @Nullable Rect disallowedAreaForEndBounds,
            DragPositioningCallbackUtility.DragStartListener dragStartListener,
            Supplier<SurfaceControl.Transaction> supplier) {
        mTaskOrganizer = taskOrganizer;
        mWindowDecoration = windowDecoration;
        mDisplayController = displayController;
        mDisallowedAreaForEndBounds.set(disallowedAreaForEndBounds);
        mDisallowedAreaForEndBounds = new Rect(disallowedAreaForEndBounds);
        mDragStartListener = dragStartListener;
        mTransactionSupplier = supplier;
    }