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

Commit e38cdc92 authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Re-parent decor SurfaceControl to task's if detached." into main

parents df383d8c 8b1ae4a3
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
            decoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */,
                    false /* setTaskCropAndPosition */,
                    mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                    /* inSyncWithTransition= */ true);
                    /* inSyncWithTransition= */ true, taskSurface);
        }
    }

@@ -272,7 +272,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
        decoration.relayout(taskInfo, startT, finishT, false /* applyStartTransactionOnDraw */,
                false /* setTaskCropAndPosition */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                /* inSyncWithTransition= */ true);
                /* inSyncWithTransition= */ true, /* taskSurface */ null);
    }

    @Override
@@ -372,7 +372,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
        windowDecoration.relayout(taskInfo, startT, finishT,
                false /* applyStartTransactionOnDraw */, false /* setTaskCropAndPosition */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo), mExclusionRegion,
                /* inSyncWithTransition= */ true);
                /* inSyncWithTransition= */ true, taskSurface);
    }

    private class CaptionTouchEventListener implements
+3 −1
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ constructor(
            hasGlobalFocus,
            displayExclusionRegion,
            inSyncWithTransition = false,
            taskSurface,
        )
        if (!applyTransactionOnDraw) {
            t.apply()
@@ -323,6 +324,7 @@ constructor(
        hasGlobalFocus: Boolean,
        displayExclusionRegion: Region,
        inSyncWithTransition: Boolean,
        taskSurface: SurfaceControl?,
    ) =
        traceSection("DefaultWindowDecoration#relayout") {
            if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_APP_TO_WEB.isTrue) {
@@ -356,7 +358,7 @@ constructor(
                )

            val wct = windowContainerTransactionSupplier.invoke()
            relayout(relayoutParams, startT, finishT, wct)
            relayout(relayoutParams, startT, finishT, wct, taskSurface)

            // After this line, taskInfo  is up-to-date and should be used instead of taskInfo
            if (!wct.isEmpty) {
+3 −3
Original line number Diff line number Diff line
@@ -657,7 +657,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                    false /* shouldSetTaskPositionAndCrop */,
                    mFocusTransitionObserver.hasGlobalFocus(taskInfo),
                    mGestureExclusionTracker.getExclusionRegion(taskInfo.displayId),
                    /* inSyncWithTransition= */ true);
                    /* inSyncWithTransition= */ true, taskSurface);
        }
    }

@@ -732,7 +732,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                false /* shouldSetTaskPositionAndCrop */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo),
                mGestureExclusionTracker.getExclusionRegion(taskInfo.displayId),
                /* inSyncWithTransition= */ true);
                /* inSyncWithTransition= */ true, /* taskSurface */ null);
    }

    @Override
@@ -2161,7 +2161,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                false /* applyStartTransactionOnDraw */, false /* shouldSetTaskPositionAndCrop */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo),
                mGestureExclusionTracker.getExclusionRegion(taskInfo.displayId),
                /* inSyncWithTransition= */ true);
                /* inSyncWithTransition= */ true, taskSurface);
        if (!DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) {
            incrementEventReceiverTasks(taskInfo.displayId);
        }
+19 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ abstract class WindowDecoration2<T>(
    private val context: Context,
    private val displayController: DisplayController,
    taskSurface: SurfaceControl,
    surfaceControlSupplier: () -> SurfaceControl,
    private val surfaceControlSupplier: () -> SurfaceControl,
    private val taskOrganizer: ShellTaskOrganizer,
    @ShellMainThread private val handler: Handler,
    private val surfaceControlBuilderSupplier: () -> SurfaceControl.Builder = {
@@ -105,7 +105,9 @@ abstract class WindowDecoration2<T>(
            }
        }
    /** The surface control of the task that owns this decoration. */
    val taskSurface = cloneSurfaceControl(taskSurface, surfaceControlSupplier)
    var taskSurface = cloneSurfaceControl(taskSurface, surfaceControlSupplier)
        private set

    protected var decorationContainerSurface: SurfaceControl? = null
    /** Sets the [TaskDragResizer] which allows task to be drag-resized. */
    var taskDragResizer: TaskDragResizer? = null
@@ -150,6 +152,7 @@ abstract class WindowDecoration2<T>(
        startT: SurfaceControl.Transaction,
        finishT: SurfaceControl.Transaction,
        wct: WindowContainerTransaction,
        newTaskSurface: SurfaceControl?,
    ): RelayoutResult<T>? =
        traceSection(
            traceTag = Trace.TRACE_TAG_WINDOW_MANAGER,
@@ -159,6 +162,20 @@ abstract class WindowDecoration2<T>(
            hasGlobalFocus = params.hasGlobalFocus
            exclusionRegion.set(params.displayExclusionRegion)

            if (
                decorationContainerSurface != null &&
                    newTaskSurface != null &&
                    !newTaskSurface.isSameSurface(taskSurface)
            ) {
                val containerSurface =
                    checkNotNull(decorationContainerSurface) {
                        "expected non-null decoration container surface"
                    }
                taskSurface.release()
                taskSurface = cloneSurfaceControl(newTaskSurface, surfaceControlSupplier)
                startT.reparent(containerSurface, taskSurface)
            }

            if (!taskInfo.isVisible) {
                releaseViews(wct)
                if (params.setTaskVisibilityPositionAndCrop) {
+2 −0
Original line number Diff line number Diff line
@@ -215,6 +215,7 @@ private constructor(
        hasGlobalFocus: Boolean,
        displayExclusionRegion: Region,
        inSyncWithTransition: Boolean,
        taskSurface: SurfaceControl?,
    ) =
        when {
            defaultWindowDecor != null -> {
@@ -228,6 +229,7 @@ private constructor(
                        hasGlobalFocus,
                        displayExclusionRegion,
                        inSyncWithTransition,
                        taskSurface,
                    )
            }