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

Commit 41173da3 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Cache last valid drag area to check if task needs to be repositioned on

display change

Previously, we checked if the task was freeform and, if so, we
calculated draggable area to see if the task needs to be repositioned
when the display is rotated.

This logic is bad because we are assuming we will get a valid drag area
if the task is in freeform (aka we have an app header) which is now not
true since the caption controller is released when the task is not
visible and should not be assumed in the first place.

The valid drag area will now be cached in the windowDecor, and, the task
will check if repositioning is needed only if the decor returns a valid
drag area.

Bug: 441287483
Test: Manual testing
Flag: EXEMPT minor bugfix
Change-Id: Icb82e53927e336ef79b783660b77a39b908eea85
parent e4fd8950
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -522,7 +522,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
                            e.getDisplayId(),
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    DragPositioningCallbackUtility.snapTaskBoundsIfNecessary(newTaskBounds,
                            mWindowDecorByTaskId.get(mTaskId).calculateValidDragArea());
                            mWindowDecorByTaskId.get(mTaskId).getValidDragArea());
                    if (newTaskBounds != taskInfo.configuration.windowConfiguration.getBounds()) {
                        final WindowContainerTransaction wct = new WindowContainerTransaction();
                        wct.setBounds(taskInfo.token, newTaskBounds);
+0 −1
Original line number Diff line number Diff line
@@ -131,7 +131,6 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
        mDragPositioningCallback = dragPositioningCallback;
    }

    @Override
    @NonNull
    Rect calculateValidDragArea() {
        final Context displayContext = mDisplayController.getDisplayContext(mTaskInfo.displayId);
+0 −6
Original line number Diff line number Diff line
@@ -121,12 +121,6 @@ public class CarWindowDecoration extends WindowDecoration<WindowDecorLinearLayou
        }
    }

    @Override
    @NonNull
    Rect calculateValidDragArea() {
        return new Rect();
    }

    @Override
    int getCaptionViewId() {
        return R.id.caption;
+1 −1
Original line number Diff line number Diff line
@@ -672,7 +672,7 @@ public class DesktopModeTouchEventListener
                // Tasks bounds haven't actually been updated (only its leash), so pass to
                // DesktopTasksController to allow secondary transformations (i.e. snap resizing
                // or transforming to fullscreen) before setting new task bounds.
                final Rect validDragArea = decoration.calculateValidDragArea();
                final Rect validDragArea = decoration.getValidDragArea();
                final boolean needDragIndicatorCleanup =
                        mDesktopTasksController.onDragPositioningEnd(
                                taskInfo, decoration.getTaskSurface(), e.getDisplayId(),
+5 −3
Original line number Diff line number Diff line
@@ -494,14 +494,16 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                }

                // Check if display has been rotated between portrait & landscape
                if (displayId == taskInfo.displayId && taskInfo.isFreeform()
                        && (fromRotation % 2 != toRotation % 2)) {
                if (displayId == taskInfo.displayId && (fromRotation % 2 != toRotation % 2)) {
                    final Rect validDragArea = decoration.getValidDragArea();
                    // If not draggable, return
                    if (validDragArea == null) return;
                    // Check if the task bounds on the rotated display will be out of bounds.
                    // If so, then update task bounds to be within reachable area.
                    final Rect taskBounds = new Rect(
                            taskInfo.configuration.windowConfiguration.getBounds());
                    if (DragPositioningCallbackUtility.snapTaskBoundsIfNecessary(
                            taskBounds, decoration.calculateValidDragArea())) {
                            taskBounds, validDragArea)) {
                        t.setBounds(taskInfo.token, taskBounds);
                    }
                }
Loading