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

Commit 8175846e authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix popup window calculation for multi-window

If ignoreBottomDecorations=true, the display size was extracted from
the resources. However, this didn't work if the parent window was in
multi-window, as all the calculations went wrong. Instead, introduce
View.getWindowDisplayFrame which returns the "full" frame of the task
the window is currently in, without any insets, and use that to
calculate the bottom edge.

Bug: 26255254
Change-Id: I8b235b335775022ae399ee082d1200aa76cc047c
parent 300efaa0
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -10269,6 +10269,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        d.getRectSize(outRect);
    }
    /**
     * Like {@link #getWindowVisibleDisplayFrame}, but returns the "full" display frame this window
     * is currently in without any insets.
     *
     * @hide
     */
    public void getWindowDisplayFrame(Rect outRect) {
        if (mAttachInfo != null) {
            try {
                mAttachInfo.mSession.getDisplayFrame(mAttachInfo.mWindow, outRect);
            } catch (RemoteException e) {
                return;
            }
            return;
        }
        // The view is not attached to a display so we don't have a context.
        // Make a best guess about the display size.
        Display d = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
        d.getRectSize(outRect);
    }
    /**
     * Dispatch a notification about a resource configuration change down
     * the view hierarchy.
+6 −9
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import com.android.internal.R;

import android.annotation.NonNull;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@@ -1587,18 +1586,16 @@ public class PopupWindow {
    public int getMaxAvailableHeight(
            @NonNull View anchor, int yOffset, boolean ignoreBottomDecorations) {
        final Rect displayFrame = new Rect();
        if (ignoreBottomDecorations) {
            anchor.getWindowDisplayFrame(displayFrame);
        } else {
            anchor.getWindowVisibleDisplayFrame(displayFrame);
        }

        final int[] anchorPos = mDrawingLocation;
        anchor.getLocationOnScreen(anchorPos);

        final int bottomEdge;
        if (ignoreBottomDecorations) {
            final Resources res = anchor.getContext().getResources();
            bottomEdge = res.getDisplayMetrics().heightPixels;
        } else {
            bottomEdge = displayFrame.bottom;
        }
        final int bottomEdge = displayFrame.bottom;

        final int distanceToBottom;
        if (mOverlapAnchor) {