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

Commit 364c9125 authored by Evan Rosky's avatar Evan Rosky
Browse files

Adjust drag regions to accomodate split-minimized home

Basically, this doesn't constrain home's drag bounds to
its stack if it is on top of its parent since sysui has
adjusted the surface crop for these cases.

On the other side, anything in the primary stack must
subtract the home's bounds from its own if home is the
top secondary task.

Bug: 154832406
Test: With a minimized dock, open quick-search and drag
      an app icon onto the launcher.
Change-Id: Id25ec11de85530b2f43ecc0dda6864077a271ba5
parent 444d74fa
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2918,7 +2918,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);