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

Commit f505da86 authored by Evan Rosky's avatar Evan Rosky Committed by Automerger Merge Worker
Browse files

Merge "Adjust drag regions to accomodate split-minimized home" into rvc-dev am: 40f7d483

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11744161

Change-Id: I9259dcbc993f82ea0ce836c970f1180a1eb59ad2
parents 84db84a6 40f7d483
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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;
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -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 -> {
+37 −0
Original line number Diff line number Diff line
@@ -1528,6 +1528,29 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                && dc != null ? dc.getDefaultTaskDisplayArea().getRootHomeTask() : null;
    }

    /**
     * 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);