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

Commit a01ac588 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android Build Coastguard Worker
Browse files

Set task position and show task on every drag end

The task position + visibility is only set when the bounds of the task
have changed. If the task is moved but returned to the same spot, the
task is moved offscreen during the drag, so we need to bring the task
back by setting position and showing the task.

Bug: 447398317
Flag: EXEMPT BUGFIX
Test: manual testing
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:50a0e4ab0099410d812d201e385c9af9ad7d62e9
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:322e42afff73daa2e0683ad11768084d613b2082
Merged-In: I077b2208858c8b1bce559ff400dd75779a98e646
Change-Id: I077b2208858c8b1bce559ff400dd75779a98e646
parent e0a893e6
Loading
Loading
Loading
Loading
+23 −12
Original line number Original line Diff line number Diff line
@@ -6006,32 +6006,43 @@ class DesktopTasksController(
                    validDragArea,
                    validDragArea,
                )
                )


                if (destinationBounds == dragStartBounds) {
                val newDisplayId = motionEvent.displayId
                val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(newDisplayId)
                val isCrossDisplayDrag =
                    DesktopExperienceFlags.ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG.isTrue() &&
                        newDisplayId != taskInfo.getDisplayId() &&
                        displayAreaInfo != null

                if (!isCrossDisplayDrag && destinationBounds == dragStartBounds) {
                    // There's no actual difference between the start and end bounds, so while a
                    // There's no actual difference between the start and end bounds, so while a
                    // WCT change isn't needed, the dragged surface still needs to be snapped back
                    // WCT change isn't needed, the dragged surface still needs to be snapped back
                    // to its original location. This is as long as it moved some in the first
                    // to its original location.
                    // place, if it didn't and |currentDragBounds| is already at destination then
                    // there's no need to animate.
                    if (currentDragBounds != dragStartBounds) {
                    if (currentDragBounds != dragStartBounds) {
                        releaseVisualIndicator()
                        // If task's position needs to be changed from the current bounds, animate
                        // the bounds change
                        returnToDragStartAnimator.start(
                        returnToDragStartAnimator.start(
                            taskInfo.taskId,
                            taskInfo.taskId,
                            taskSurface,
                            taskSurface,
                            startBounds = currentDragBounds,
                            startBounds = currentDragBounds,
                            endBounds = dragStartBounds,
                            endBounds = dragStartBounds,
                        )
                        )
                    } else {
                        // Set the task bounds even if there is no difference between the current
                        // bounds and destination bounds in case that task surface was moved off
                        // screen during the drag
                        val t = SurfaceControl.Transaction()
                        t.setPosition(
                            taskSurface,
                            destinationBounds.left.toFloat(),
                            destinationBounds.top.toFloat(),
                        )
                        t.apply()
                    }
                    }
                    releaseVisualIndicator()
                    return true
                    return true
                }
                }


                val newDisplayId = motionEvent.displayId
                val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(newDisplayId)
                val isCrossDisplayDrag =
                    DesktopExperienceFlags.ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG.isTrue() &&
                        newDisplayId != taskInfo.getDisplayId() &&
                        displayAreaInfo != null
                val prevCaptionInsets = taskInfo.freeformCaptionInsets
                val prevCaptionInsets = taskInfo.freeformCaptionInsets

                if (isCrossDisplayDrag) {
                if (isCrossDisplayDrag) {
                    val captionInsetsDp =
                    val captionInsetsDp =
                        displayController
                        displayController