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

Commit eb9fea9f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent unnecessary animation when dragging window within same display" into main

parents e1c0ffb8 c6fb62e9
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -237,8 +237,12 @@ class MultiDisplayVeiledResizeTaskPositioner(
            val startDisplayLayout = displayController.getDisplayLayout(startDisplayId)
            val startDisplayLayout = displayController.getDisplayLayout(startDisplayId)
            val currentDisplayLayout = displayController.getDisplayLayout(displayId)
            val currentDisplayLayout = displayController.getDisplayLayout(displayId)


            if (startDisplayLayout == null || currentDisplayLayout == null) {
            if (startDisplayId == displayId
                // Fall back to single-display drag behavior if any display layout is unavailable.
                || startDisplayLayout == null || currentDisplayLayout == null) {
                // Fall back to single-display drag behavior if:
                // 1. The drag destination display is the same as the start display. This prevents
                // unnecessary animations caused by minor width/height changes due to DPI scaling.
                // 2. Either the starting or current display layout is unavailable.
                DragPositioningCallbackUtility.updateTaskBounds(
                DragPositioningCallbackUtility.updateTaskBounds(
                    repositionTaskBounds,
                    repositionTaskBounds,
                    taskBoundsAtDragStart,
                    taskBoundsAtDragStart,
+19 −0
Original line number Original line Diff line number Diff line
@@ -248,6 +248,25 @@ class MultiDisplayVeiledResizeTaskPositionerTest : ShellTestCase() {
        Assert.assertEquals(rectAfterEnd, endBounds)
        Assert.assertEquals(rectAfterEnd, endBounds)
    }
    }


    @Test
    fun testDragResize_movesTaskOnSameDisplay_noPxDpConversion() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
            CTRL_TYPE_UNDEFINED,
            DISPLAY_ID_0,
            STARTING_BOUNDS.left.toFloat(),
            STARTING_BOUNDS.top.toFloat(),
        )

        taskPositioner.onDragPositioningEnd(
            DISPLAY_ID_0,
            STARTING_BOUNDS.left.toFloat() + 70,
            STARTING_BOUNDS.top.toFloat() + 20,
        )

        verify(spyDisplayLayout0, never()).localPxToGlobalDp(any(), any())
        verify(spyDisplayLayout0, never()).globalDpToLocalPx(any(), any())
    }

    @Test
    @Test
    fun testDragResize_movesTaskToNewDisplay() = runOnUiThread {
    fun testDragResize_movesTaskToNewDisplay() = runOnUiThread {
        taskPositioner.onDragPositioningStart(
        taskPositioner.onDragPositioningStart(