summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/Task.java7
-rw-r--r--services/core/java/com/android/server/wm/TaskDisplayArea.java9
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java37
3 files changed, 52 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 0ead575051a1..c749125ec531 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -2924,7 +2924,12 @@ class Task extends WindowContainer<WindowContainer> {
}
boolean cropWindowsToStackBounds() {
- return isResizeable();
+ // Don't crop HOME/RECENTS windows to stack bounds. This is because in split-screen
+ // they extend past their stack and sysui uses the stack surface to control cropping.
+ // TODO(b/158242495): get rid of this when drag/drop can use surface bounds.
+ final boolean isTopHomeOrRecents = (isActivityTypeHome() || isActivityTypeRecents())
+ && getRootTask().getTopMostTask() == this;
+ return isResizeable() && !isTopHomeOrRecents;
}
/**
diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java
index f793bd269cc9..6b8800a8eb0a 100644
--- a/services/core/java/com/android/server/wm/TaskDisplayArea.java
+++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java
@@ -207,6 +207,15 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> {
return mRootSplitScreenPrimaryTask;
}
+ ActivityStack getRootSplitScreenSecondaryTask() {
+ for (int i = mChildren.size() - 1; i >= 0; --i) {
+ if (mChildren.get(i).inSplitScreenSecondaryWindowingMode()) {
+ return mChildren.get(i);
+ }
+ }
+ return null;
+ }
+
ArrayList<Task> getVisibleTasks() {
final ArrayList<Task> visibleTasks = new ArrayList<>();
forAllTasks(task -> {
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index e20afb4d714c..6bbc019ed5e7 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1529,6 +1529,29 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
/**
+ * This is a form of rectangle "difference". It cut off each dimension of rect by the amount
+ * that toRemove is "pushing into" it from the outside. Any dimension that fully contains
+ * toRemove won't change.
+ */
+ private void cutRect(Rect rect, Rect toRemove) {
+ if (toRemove.isEmpty()) return;
+ if (toRemove.top < rect.bottom && toRemove.bottom > rect.top) {
+ if (toRemove.right >= rect.right && toRemove.left >= rect.left) {
+ rect.right = toRemove.left;
+ } else if (toRemove.left <= rect.left && toRemove.right <= rect.right) {
+ rect.left = toRemove.right;
+ }
+ }
+ if (toRemove.left < rect.right && toRemove.right > rect.left) {
+ if (toRemove.bottom >= rect.bottom && toRemove.top >= rect.top) {
+ rect.bottom = toRemove.top;
+ } else if (toRemove.top <= rect.top && toRemove.bottom <= rect.bottom) {
+ rect.top = toRemove.bottom;
+ }
+ }
+ }
+
+ /**
* Retrieves the visible bounds of the window.
* @param bounds The rect which gets the bounds.
*/
@@ -1544,6 +1567,20 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
} else {
intersectWithStackBounds = false;
}
+ if (inSplitScreenPrimaryWindowingMode()) {
+ // If this is in the primary split and the home stack is the top visible task in
+ // the secondary split, it means this is "minimized" and thus must prevent
+ // overlapping with home.
+ // TODO(b/158242495): get rid of this when drag/drop can use surface bounds.
+ final ActivityStack rootSecondary =
+ task.getDisplayArea().getRootSplitScreenSecondaryTask();
+ if (rootSecondary.isActivityTypeHome() || rootSecondary.isActivityTypeRecents()) {
+ final WindowContainer topTask = rootSecondary.getTopChild();
+ if (topTask.isVisible()) {
+ cutRect(mTmpRect, topTask.getBounds());
+ }
+ }
+ }
}
bounds.set(mWindowFrames.mVisibleFrame);