From bd8b345337012e7d40ab1ff4043bab6eea6c72bf Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Tue, 2 Nov 2021 16:50:18 +0800 Subject: [PATCH] Support to transfer freeform task into split screen Clear overrided windowing mode and window bounds when a task vanished from freeform task organizer to make sure the task can inherit config from its new parent. Fix: 204842882 Test: put a task in freeform, then trigger split screen with such task, observed it applied multi-window windowing mode and bounds properly. Change-Id: Ifb100d17a83931237e58bcd774dce304a3fdb731 --- .../android/wm/shell/freeform/FreeformTaskListener.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskListener.java index 5fb3297aa6d30..8a8d7c68d9f64 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskListener.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskListener.java @@ -16,6 +16,7 @@ package com.android.wm.shell.freeform; +import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT; import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT; @@ -27,6 +28,7 @@ import android.provider.Settings; import android.util.Slog; import android.util.SparseArray; import android.view.SurfaceControl; +import android.window.WindowContainerTransaction; import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.ShellTaskOrganizer; @@ -83,6 +85,13 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener { Slog.e(TAG, "Task already vanished: #" + taskInfo.taskId); return; } + + // Clears windowing mode and window bounds to let the task inherits from its new parent. + final WindowContainerTransaction wct = new WindowContainerTransaction(); + wct.setBounds(taskInfo.token, null) + .setWindowingMode(taskInfo.token, WINDOWING_MODE_UNDEFINED); + mSyncQueue.queue(wct); + ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Freeform Task Vanished: #%d", taskInfo.taskId); mTasks.remove(taskInfo.taskId);