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

Commit ca3fc58b authored by Shuming Hao's avatar Shuming Hao Committed by Android (Google) Code Review
Browse files

Merge "Allow split pair to move to external display" into main

parents ea55a5ff 870e28b7
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -1018,6 +1018,23 @@ class DesktopTasksController(
        }

        val wct = WindowContainerTransaction()

        // check if the task is part of splitscreen
        if (
            Flags.enableNonDefaultDisplaySplit() &&
                Flags.enableMoveToNextDisplayShortcut() &&
                splitScreenController.isTaskInSplitScreen(task.taskId)
        ) {
            val stageCoordinatorRootTaskToken =
                splitScreenController.multiDisplayProvider.getDisplayRootForDisplayId(
                    DEFAULT_DISPLAY
                )

            wct.reparent(stageCoordinatorRootTaskToken, displayAreaInfo.token, true /* onTop */)
            transitions.startTransition(TRANSIT_CHANGE, wct, /* handler= */ null)
            return
        }

        if (!task.isFreeform) {
            addMoveToDesktopChanges(wct, task, displayId)
        } else if (Flags.enableMoveToNextDisplayShortcut()) {
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.splitscreen;

import android.window.WindowContainerToken;

public interface SplitMultiDisplayProvider {
    /**
     * Returns the WindowContainerToken for the root of the given display ID.
     *
     * @param displayId The ID of the display.
     * @return The {@link WindowContainerToken} associated with the display's root task.
     */
    WindowContainerToken getDisplayRootForDisplayId(int displayId);
}
+4 −0
Original line number Diff line number Diff line
@@ -321,6 +321,10 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        return mStageCoordinator;
    }

    public SplitMultiDisplayProvider getMultiDisplayProvider() {
        return mStageCoordinator;
    }

    @Nullable
    public ActivityManager.RunningTaskInfo getTaskInfo(@SplitPosition int splitPosition) {
        if (!isSplitScreenVisible() || splitPosition == SPLIT_POSITION_UNDEFINED) {
+12 −1
Original line number Diff line number Diff line
@@ -189,7 +189,8 @@ import java.util.function.Predicate;
 */
public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        DisplayController.OnDisplaysChangedListener, Transitions.TransitionHandler,
        ShellTaskOrganizer.TaskListener, StageTaskListener.StageListenerCallbacks {
        ShellTaskOrganizer.TaskListener, StageTaskListener.StageListenerCallbacks,
        SplitMultiDisplayProvider {

    private static final String TAG = StageCoordinator.class.getSimpleName();

@@ -287,6 +288,16 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        mSplitTransitions.registerSplitAnimListener(listener, executor);
    }

    @Override
    public WindowContainerToken getDisplayRootForDisplayId(int displayId) {
        if (displayId == DEFAULT_DISPLAY) {
            return mRootTaskInfo != null ? mRootTaskInfo.token : null;
        }

        // TODO(b/393217881): support different root task on external displays.
        return null; // Return null for unknown display IDs
    }

    class SplitRequest {
        @SplitPosition
        int mActivatePosition;