Merge "Bring task to front when resizing" into udc-dev

This commit is contained in:
Maryam Dehaini
2023-05-10 20:31:24 +00:00
committed by Android (Google) Code Review
4 changed files with 108 additions and 0 deletions

View File

@@ -73,6 +73,11 @@ class FluidResizeTaskPositioner implements DragPositioningCallback {
mWindowDecoration.mTaskInfo.configuration.windowConfiguration.getBounds());
mRepositionStartPoint.set(x, y);
mDragStartListener.onDragStart(mWindowDecoration.mTaskInfo.taskId);
if (mCtrlType != CTRL_TYPE_UNDEFINED && !mWindowDecoration.mTaskInfo.isFocused) {
WindowContainerTransaction wct = new WindowContainerTransaction();
wct.reorder(mWindowDecoration.mTaskInfo.token, true);
mTaskOrganizer.applyTransaction(wct);
}
mRepositionTaskBounds.set(mTaskBoundsAtDragStart);
}

View File

@@ -78,6 +78,11 @@ public class VeiledResizeTaskPositioner implements DragPositioningCallback {
mRepositionStartPoint.set(x, y);
if (isResizing()) {
mDesktopWindowDecoration.showResizeVeil();
if (!mDesktopWindowDecoration.mTaskInfo.isFocused) {
WindowContainerTransaction wct = new WindowContainerTransaction();
wct.reorder(mDesktopWindowDecoration.mTaskInfo.token, true);
mTaskOrganizer.applyTransaction(wct);
}
}
mHasDragResized = false;
mDragStartListener.onDragStart(mDesktopWindowDecoration.mTaskInfo.taskId);

View File

@@ -565,6 +565,55 @@ class FluidResizeTaskPositionerTest : ShellTestCase() {
bounds == configuration.windowConfiguration.bounds
}
@Test
fun testDragResize_resize_resizingTaskReorderedToTopWhenNotFocused() {
mockWindowDecoration.mTaskInfo.isFocused = false
taskPositioner.onDragPositioningStart(
CTRL_TYPE_RIGHT, // Resize right
STARTING_BOUNDS.left.toFloat(),
STARTING_BOUNDS.top.toFloat()
)
// Verify task is reordered to top
verify(mockShellTaskOrganizer).applyTransaction(argThat { wct ->
return@argThat wct.hierarchyOps.any { hierarchyOps ->
hierarchyOps.container == taskBinder && hierarchyOps.toTop }
})
}
@Test
fun testDragResize_resize_resizingTaskNotReorderedToTopWhenFocused() {
mockWindowDecoration.mTaskInfo.isFocused = true
taskPositioner.onDragPositioningStart(
CTRL_TYPE_RIGHT, // Resize right
STARTING_BOUNDS.left.toFloat(),
STARTING_BOUNDS.top.toFloat()
)
// Verify task is not reordered to top
verify(mockShellTaskOrganizer, never()).applyTransaction(argThat { wct ->
return@argThat wct.hierarchyOps.any { hierarchyOps ->
hierarchyOps.container == taskBinder && hierarchyOps.toTop }
})
}
@Test
fun testDragResize_drag_draggedTaskNotReorderedToTop() {
mockWindowDecoration.mTaskInfo.isFocused = false
taskPositioner.onDragPositioningStart(
CTRL_TYPE_UNDEFINED, // drag
STARTING_BOUNDS.left.toFloat(),
STARTING_BOUNDS.top.toFloat()
)
// Verify task is not reordered to top since task is already brought to top before dragging
// begins
verify(mockShellTaskOrganizer, never()).applyTransaction(argThat { wct ->
return@argThat wct.hierarchyOps.any { hierarchyOps ->
hierarchyOps.container == taskBinder && hierarchyOps.toTop }
})
}
companion object {
private const val TASK_ID = 5
private const val MIN_WIDTH = 10

View File

@@ -271,6 +271,55 @@ class VeiledResizeTaskPositionerTest : ShellTestCase() {
})
}
@Test
fun testDragResize_resize_resizingTaskReorderedToTopWhenNotFocused() {
mockDesktopWindowDecoration.mTaskInfo.isFocused = false
taskPositioner.onDragPositioningStart(
CTRL_TYPE_RIGHT, // Resize right
STARTING_BOUNDS.left.toFloat(),
STARTING_BOUNDS.top.toFloat()
)
// Verify task is reordered to top
verify(mockShellTaskOrganizer).applyTransaction(argThat { wct ->
return@argThat wct.hierarchyOps.any { hierarchyOps ->
hierarchyOps.container == taskBinder && hierarchyOps.toTop }
})
}
@Test
fun testDragResize_resize_resizingTaskNotReorderedToTopWhenFocused() {
mockDesktopWindowDecoration.mTaskInfo.isFocused = true
taskPositioner.onDragPositioningStart(
CTRL_TYPE_RIGHT, // Resize right
STARTING_BOUNDS.left.toFloat(),
STARTING_BOUNDS.top.toFloat()
)
// Verify task is not reordered to top
verify(mockShellTaskOrganizer, never()).applyTransaction(argThat { wct ->
return@argThat wct.hierarchyOps.any { hierarchyOps ->
hierarchyOps.container == taskBinder && hierarchyOps.toTop }
})
}
@Test
fun testDragResize_drag_draggedTaskNotReorderedToTop() {
mockDesktopWindowDecoration.mTaskInfo.isFocused = false
taskPositioner.onDragPositioningStart(
CTRL_TYPE_UNDEFINED, // drag
STARTING_BOUNDS.left.toFloat(),
STARTING_BOUNDS.top.toFloat()
)
// Verify task is not reordered to top since task is already brought to top before dragging
// begins
verify(mockShellTaskOrganizer, never()).applyTransaction(argThat { wct ->
return@argThat wct.hierarchyOps.any { hierarchyOps ->
hierarchyOps.container == taskBinder && hierarchyOps.toTop }
})
}
companion object {
private const val TASK_ID = 5
private const val MIN_WIDTH = 10