diff options
| author | 2025-03-13 23:56:47 -0700 | |
|---|---|---|
| committer | 2025-03-13 23:56:47 -0700 | |
| commit | 924f523ca7fc402dcf8fe6f05b2c738ec092f88f (patch) | |
| tree | af25667bd2fe1dd024a7a1f5f09a6015de940aae | |
| parent | 3e77e629bd925235879f550bb2d8819903d57a84 (diff) | |
| parent | eb84c309b08db166da26aabae994dda362565867 (diff) | |
Merge "Let nested multi-window inherit bounds from parent" into main
| -rw-r--r-- | core/java/android/app/WindowConfiguration.java | 6 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/Task.java | 80 |
2 files changed, 53 insertions, 33 deletions
diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java index c6d0f61b529e..8c99bd8e2ed9 100644 --- a/core/java/android/app/WindowConfiguration.java +++ b/core/java/android/app/WindowConfiguration.java @@ -790,12 +790,6 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu || mWindowingMode == WINDOWING_MODE_MULTI_WINDOW; } - /** Returns true if the task bounds should persist across power cycles. - * @hide */ - public boolean persistTaskBounds() { - return mWindowingMode == WINDOWING_MODE_FREEFORM; - } - /** * Returns true if the tasks associated with this window configuration are floating. * Floating tasks are laid out differently as they are allowed to extend past the display bounds diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 8587b5a9c7ca..0531828be6d4 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1832,6 +1832,17 @@ class Task extends TaskFragment { && supportsMultiWindowInDisplayArea(tda); } + /** Returns true if the task bounds should persist across power cycles. */ + private static boolean persistTaskBounds(@NonNull WindowConfiguration configuration) { + return configuration.getWindowingMode() == WINDOWING_MODE_FREEFORM; + } + + /** Returns true if the nested task is allowed to have independent bounds from its parent. */ + private static boolean allowIndependentBoundsFromParent( + @NonNull WindowConfiguration configuration) { + return configuration.getWindowingMode() == WINDOWING_MODE_FREEFORM; + } + /** * Check whether this task can be launched on the specified display. * @@ -1996,11 +2007,11 @@ class Task extends TaskFragment { private void onConfigurationChangedInner(Configuration newParentConfig) { // Check if the new configuration supports persistent bounds (eg. is Freeform) and if so // restore the last recorded non-fullscreen bounds. - final boolean prevPersistTaskBounds = getWindowConfiguration().persistTaskBounds(); - boolean nextPersistTaskBounds = - getRequestedOverrideConfiguration().windowConfiguration.persistTaskBounds(); + final boolean prevPersistTaskBounds = persistTaskBounds(getWindowConfiguration()); + boolean nextPersistTaskBounds = persistTaskBounds( + getRequestedOverrideConfiguration().windowConfiguration); if (getRequestedOverrideWindowingMode() == WINDOWING_MODE_UNDEFINED) { - nextPersistTaskBounds = newParentConfig.windowConfiguration.persistTaskBounds(); + nextPersistTaskBounds = persistTaskBounds(newParentConfig.windowConfiguration); } // Only restore to the last non-fullscreen bounds when the requested override bounds // have not been explicitly set already. @@ -2042,7 +2053,7 @@ class Task extends TaskFragment { // If the configuration supports persistent bounds (eg. Freeform), keep track of the // current (non-fullscreen) bounds for persistence. - if (getWindowConfiguration().persistTaskBounds()) { + if (persistTaskBounds(getWindowConfiguration())) { final Rect currentBounds = getRequestedOverrideBounds(); if (!currentBounds.isEmpty()) { setLastNonFullscreenBounds(currentBounds); @@ -2383,33 +2394,48 @@ class Task extends TaskFragment { } void updateOverrideConfigurationFromLaunchBounds() { - // If the task is controlled by another organized task, do not set override - // configurations and let its parent (organized task) to control it; final Task rootTask = getRootTask(); - boolean shouldInheritBounds = rootTask != this && rootTask.isOrganized(); - if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()) { - // Only inherit from organized parent when this task is not organized. - shouldInheritBounds &= !isOrganized(); + final boolean hasParentTask = rootTask != this; + final int windowingMode = getWindowingMode(); + final boolean isNonStandardOrFullscreen = !isActivityTypeStandardOrUndefined() + || windowingMode == WINDOWING_MODE_FULLSCREEN; + if (!Flags.nestedTasksWithIndependentBounds() + && !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()) { + final Rect bounds; + if (hasParentTask && rootTask.isOrganized()) { + bounds = null; + } else if (isNonStandardOrFullscreen) { + bounds = isResizeable() ? rootTask.getRequestedOverrideBounds() : null; + } else if (!persistTaskBounds(getWindowConfiguration())) { + bounds = rootTask.getRequestedOverrideBounds(); + } else { + bounds = mLastNonFullscreenBounds; + } + setBounds(bounds); + return; } - final Rect bounds = shouldInheritBounds ? null : getLaunchBounds(); - setBounds(bounds); - } - /** Returns the bounds that should be used to launch this task. */ - Rect getLaunchBounds() { - final Task rootTask = getRootTask(); - if (rootTask == null) { - return null; + // Non-standard/fullscreen unresizable tasks should always inherit. + boolean shouldInheritBounds = isNonStandardOrFullscreen && !isResizeable(); + // Task itself is not organized (e.g. Home), just inherit from its organized parent. + shouldInheritBounds |= hasParentTask && rootTask.isOrganized() && !isOrganized(); + // Nested tasks should inherit when they're not allowed to have independent bounds, such as + // in multi-window split-screen. + shouldInheritBounds |= hasParentTask + && !(allowIndependentBoundsFromParent(getWindowConfiguration()) + && persistTaskBounds(getWindowConfiguration())); + if (shouldInheritBounds) { + setBounds(null); + return; } - - final int windowingMode = getWindowingMode(); - if (!isActivityTypeStandardOrUndefined() - || windowingMode == WINDOWING_MODE_FULLSCREEN) { - return isResizeable() ? rootTask.getRequestedOverrideBounds() : null; - } else if (!getWindowConfiguration().persistTaskBounds()) { - return rootTask.getRequestedOverrideBounds(); + if (!hasParentTask && !persistTaskBounds(getWindowConfiguration())) { + // Non-nested, non-persistable tasks such as PIP or multi-window floating windows. + return; } - return mLastNonFullscreenBounds; + // Non-nested, persisted tasks (e.g. top-level freeform) or nested persisted tasks that + // allow independent bounds from parent (e.g. nested freeform) should use launch-params + // bounds set to |mLastNonFullscreenBounds|. + setBounds(mLastNonFullscreenBounds); } void setRootProcess(WindowProcessController proc) { |