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

Commit 5ecc25da authored by Yuichiro Hanada's avatar Yuichiro Hanada
Browse files

Set corner radius for a drag move indicator

This CL includes the following changes:
- Pass the context associated with a display where the indicator is in
  to the indicator to get the correct corner radius value
- Remove the unneeded Context from the argument of the constructor of
  the factory

Bug: 395554213
Test: manual - go/cd-smoke
Test: WMShellUnitTests
Flag: com.android.window.flags.enable_connected_displays_window_drag
Change-Id: I46354de0a2049fca11863f320da80c3b2392f640
parent 2cb71cc1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class MultiDisplayDragMoveIndicatorController(
                    continue
                }
                val displayLayout = displayController.getDisplayLayout(displayId) ?: continue
                val displayContext = displayController.getDisplayContext(displayId) ?: continue
                val shouldBeVisible =
                    RectF.intersects(RectF(boundsDp), displayLayout.globalBoundsDp())
                if (
@@ -88,6 +89,7 @@ class MultiDisplayDragMoveIndicatorController(
                        indicatorSurfaceFactory.create(
                            taskInfo,
                            displayController.getDisplay(displayId),
                            displayContext,
                        )
                    newIndicator.show(
                        transactionSupplier(),
+7 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.SurfaceControl
import android.window.TaskConstants
import androidx.compose.ui.graphics.toArgb
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.shared.R
import com.android.wm.shell.windowdecor.common.DecorThemeUtil

/**
@@ -46,6 +47,8 @@ class MultiDisplayDragMoveIndicatorSurface(
    private var veilSurface: SurfaceControl? = null

    private val decorThemeUtil = DecorThemeUtil(context)
    private val cornerRadius = context.resources
        .getDimensionPixelSize(R.dimen.desktop_windowing_freeform_rounded_corner_radius).toFloat()

    init {
        Trace.beginSection("DragIndicatorSurface#init")
@@ -108,13 +111,13 @@ class MultiDisplayDragMoveIndicatorSurface(
        }
        isVisible = shouldBeVisible
        val veil = veilSurface ?: return
        transaction.setCrop(veil, bounds)
        transaction.setCrop(veil, bounds).setCornerRadius(veil, cornerRadius)
    }

    /**
     * Factory for creating [MultiDisplayDragMoveIndicatorSurface] instances with the [context].
     */
    class Factory(private val context: Context) {
    class Factory() {
        private val surfaceControlBuilderFactory: SurfaceControlBuilderFactory =
            object : SurfaceControlBuilderFactory {}

@@ -125,8 +128,9 @@ class MultiDisplayDragMoveIndicatorSurface(
        fun create(
            taskInfo: RunningTaskInfo,
            display: Display,
            displayContext: Context,
        ) = MultiDisplayDragMoveIndicatorSurface(
            context,
            displayContext,
            taskInfo,
            display,
            surfaceControlBuilderFactory,
+2 −2
Original line number Diff line number Diff line
@@ -1133,8 +1133,8 @@ public abstract class WMShellModule {
    @WMSingleton
    @Provides
    static MultiDisplayDragMoveIndicatorSurface.Factory
            providesMultiDisplayDragMoveIndicatorSurfaceFactory(Context context) {
        return new MultiDisplayDragMoveIndicatorSurface.Factory(context);
            providesMultiDisplayDragMoveIndicatorSurfaceFactory() {
        return new MultiDisplayDragMoveIndicatorSurface.Factory();
    }

    @WMSingleton
+6 −5
Original line number Diff line number Diff line
@@ -94,10 +94,11 @@ class MultiDisplayDragMoveIndicatorControllerTest : ShellTestCase() {
        taskInfo.taskId = TASK_ID
        whenever(displayController.getDisplayLayout(0)).thenReturn(spyDisplayLayout0)
        whenever(displayController.getDisplayLayout(1)).thenReturn(spyDisplayLayout1)
        whenever(displayController.getDisplayContext(any())).thenReturn(mContext)
        whenever(displayController.getDisplay(0)).thenReturn(display0)
        whenever(displayController.getDisplay(1)).thenReturn(display1)
        whenever(indicatorSurfaceFactory.create(taskInfo, display0)).thenReturn(indicatorSurface0)
        whenever(indicatorSurfaceFactory.create(taskInfo, display1)).thenReturn(indicatorSurface1)
        whenever(indicatorSurfaceFactory.create(eq(taskInfo), eq(display0), any())).thenReturn(indicatorSurface0)
        whenever(indicatorSurfaceFactory.create(eq(taskInfo), eq(display1), any())).thenReturn(indicatorSurface1)
        whenever(transactionSupplier.get()).thenReturn(transaction)
    }

@@ -111,7 +112,7 @@ class MultiDisplayDragMoveIndicatorControllerTest : ShellTestCase() {
        ) { transaction }
        executor.flushAll()

        verify(indicatorSurfaceFactory, never()).create(any(), any())
        verify(indicatorSurfaceFactory, never()).create(any(), any(), any())
    }

    @Test
@@ -124,7 +125,7 @@ class MultiDisplayDragMoveIndicatorControllerTest : ShellTestCase() {
        ) { transaction }
        executor.flushAll()

        verify(indicatorSurfaceFactory, never()).create(any(), any())
        verify(indicatorSurfaceFactory, never()).create(any(), any(), any())
    }

    @Test
@@ -137,7 +138,7 @@ class MultiDisplayDragMoveIndicatorControllerTest : ShellTestCase() {
        ) { transaction }
        executor.flushAll()

        verify(indicatorSurfaceFactory, times(1)).create(taskInfo, display1)
        verify(indicatorSurfaceFactory, times(1)).create(eq(taskInfo), eq(display1), any())
        verify(indicatorSurface1, times(1))
            .show(transaction, taskInfo, rootTaskDisplayAreaOrganizer, 1, Rect(0, 1800, 200, 2400))