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

Commit d50231ad authored by Gaurav Bhola's avatar Gaurav Bhola Committed by Android (Google) Code Review
Browse files

Merge "Move insets related logic from WindowState to WindowContainer."

parents 909c8bbe f60944f1
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -1362,8 +1362,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return mDisplayRotation;
        return mDisplayRotation;
    }
    }


    void setInsetProvider(@InternalInsetsType int type, WindowState win,
    void setInsetProvider(@InternalInsetsType int type, WindowContainer win,
            @Nullable TriConsumer<DisplayFrames, WindowState, Rect> frameProvider){
            @Nullable TriConsumer<DisplayFrames, WindowContainer, Rect> frameProvider) {
        setInsetProvider(type, win, frameProvider, null /* imeFrameProvider */);
        setInsetProvider(type, win, frameProvider, null /* imeFrameProvider */);
    }
    }


@@ -1377,10 +1377,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     * @param imeFrameProvider Function to compute the frame when dispatching insets to the IME, or
     * @param imeFrameProvider Function to compute the frame when dispatching insets to the IME, or
     *                         {@code null} if the normal frame should be taken.
     *                         {@code null} if the normal frame should be taken.
     */
     */
    void setInsetProvider(@InternalInsetsType int type, WindowState win,
    void setInsetProvider(@InternalInsetsType int type, WindowContainer win,
            @Nullable TriConsumer<DisplayFrames, WindowState, Rect> frameProvider,
            @Nullable TriConsumer<DisplayFrames, WindowContainer, Rect> frameProvider,
            @Nullable TriConsumer<DisplayFrames, WindowState, Rect> imeFrameProvider) {
            @Nullable TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider) {
        mInsetsStateController.getSourceProvider(type).setWindow(win, frameProvider,
        mInsetsStateController.getSourceProvider(type).setWindowContainer(win, frameProvider,
                imeFrameProvider);
                imeFrameProvider);
    }
    }


@@ -3822,7 +3822,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            final int imePid = mInputMethodWindow.mSession.mPid;
            final int imePid = mInputMethodWindow.mSession.mPid;
            mAtmService.onImeWindowSetOnDisplayArea(imePid, mImeWindowsContainer);
            mAtmService.onImeWindowSetOnDisplayArea(imePid, mImeWindowsContainer);
        }
        }
        mInsetsStateController.getSourceProvider(ITYPE_IME).setWindow(win,
        mInsetsStateController.getSourceProvider(ITYPE_IME).setWindowContainer(win,
                mDisplayPolicy.getImeSourceFrameProvider(), null /* imeFrameProvider */);
                mDisplayPolicy.getImeSourceFrameProvider(), null /* imeFrameProvider */);
        computeImeTarget(true /* updateImeTarget */);
        computeImeTarget(true /* updateImeTarget */);
        updateImeControlTarget();
        updateImeControlTarget();
+28 −21
Original line number Original line Diff line number Diff line
@@ -1106,8 +1106,8 @@ public class DisplayPolicy {
                break;
                break;
            case TYPE_STATUS_BAR:
            case TYPE_STATUS_BAR:
                mStatusBar = win;
                mStatusBar = win;
                final TriConsumer<DisplayFrames, WindowState, Rect> gestureFrameProvider =
                final TriConsumer<DisplayFrames, WindowContainer, Rect> gestureFrameProvider =
                        (displayFrames, windowState, rect) -> {
                        (displayFrames, windowContainer, rect) -> {
                            rect.bottom = rect.top + getStatusBarHeight(displayFrames);
                            rect.bottom = rect.top + getStatusBarHeight(displayFrames);
                            final DisplayCutout cutout =
                            final DisplayCutout cutout =
                                    displayFrames.mInsetsState.getDisplayCutout();
                                    displayFrames.mInsetsState.getDisplayCutout();
@@ -1128,24 +1128,25 @@ public class DisplayPolicy {
            case TYPE_NAVIGATION_BAR:
            case TYPE_NAVIGATION_BAR:
                mNavigationBar = win;
                mNavigationBar = win;
                mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win,
                mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            if (!mNavButtonForcedVisible) {
                            if (!mNavButtonForcedVisible) {
                                inOutFrame.inset(windowState.getLayoutingAttrs(
                                inOutFrame.inset(win.getLayoutingAttrs(
                                        displayFrames.mRotation).providedInternalInsets);
                                        displayFrames.mRotation).providedInternalInsets);
                                inOutFrame.inset(win.mGivenContentInsets);
                                inOutFrame.inset(win.mGivenContentInsets);
                            }
                            }
                        },
                        },


                        // For IME we use regular frame.
                        // For IME we use regular frame.
                        (displayFrames, windowState, inOutFrame) ->
                        (displayFrames, windowContainer, inOutFrame) -> {
                                inOutFrame.set(windowState.getFrame()));
                            inOutFrame.set(win.getFrame());
                        });


                mDisplayContent.setInsetProvider(ITYPE_BOTTOM_MANDATORY_GESTURES, win,
                mDisplayContent.setInsetProvider(ITYPE_BOTTOM_MANDATORY_GESTURES, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            inOutFrame.top -= mBottomGestureAdditionalInset;
                            inOutFrame.top -= mBottomGestureAdditionalInset;
                        });
                        });
                mDisplayContent.setInsetProvider(ITYPE_LEFT_GESTURES, win,
                mDisplayContent.setInsetProvider(ITYPE_LEFT_GESTURES, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            final int leftSafeInset =
                            final int leftSafeInset =
                                    Math.max(displayFrames.mDisplayCutoutSafe.left, 0);
                                    Math.max(displayFrames.mDisplayCutoutSafe.left, 0);
                            inOutFrame.left = 0;
                            inOutFrame.left = 0;
@@ -1154,7 +1155,7 @@ public class DisplayPolicy {
                            inOutFrame.right = leftSafeInset + mLeftGestureInset;
                            inOutFrame.right = leftSafeInset + mLeftGestureInset;
                        });
                        });
                mDisplayContent.setInsetProvider(ITYPE_RIGHT_GESTURES, win,
                mDisplayContent.setInsetProvider(ITYPE_RIGHT_GESTURES, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            final int rightSafeInset =
                            final int rightSafeInset =
                                    Math.min(displayFrames.mDisplayCutoutSafe.right,
                                    Math.min(displayFrames.mDisplayCutoutSafe.right,
                                            displayFrames.mUnrestricted.right);
                                            displayFrames.mUnrestricted.right);
@@ -1164,8 +1165,8 @@ public class DisplayPolicy {
                            inOutFrame.right = displayFrames.mDisplayWidth;
                            inOutFrame.right = displayFrames.mDisplayWidth;
                        });
                        });
                mDisplayContent.setInsetProvider(ITYPE_BOTTOM_TAPPABLE_ELEMENT, win,
                mDisplayContent.setInsetProvider(ITYPE_BOTTOM_TAPPABLE_ELEMENT, win,
                        (displayFrames, windowState, inOutFrame) -> {
                        (displayFrames, windowContainer, inOutFrame) -> {
                            if ((windowState.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0
                            if ((win.getAttrs().flags & FLAG_NOT_TOUCHABLE) != 0
                                    || mNavigationBarLetsThroughTaps) {
                                    || mNavigationBarLetsThroughTaps) {
                                inOutFrame.setEmpty();
                                inOutFrame.setEmpty();
                            }
                            }
@@ -1176,11 +1177,13 @@ public class DisplayPolicy {
            default:
            default:
                if (attrs.providesInsetsTypes != null) {
                if (attrs.providesInsetsTypes != null) {
                    for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) {
                    for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) {
                        final TriConsumer<DisplayFrames, WindowState, Rect> imeFrameProvider =
                        final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
                                !attrs.providedInternalImeInsets.equals(Insets.NONE)
                                !attrs.providedInternalImeInsets.equals(Insets.NONE)
                                        ? (displayFrames, windowState, inOutFrame) ->
                                        ? (displayFrames, windowContainer, inOutFrame) -> {
                                        inOutFrame.inset(windowState.getLayoutingAttrs(
                                            inOutFrame.inset(win.getLayoutingAttrs(
                                                displayFrames.mRotation).providedInternalImeInsets)
                                                    displayFrames.mRotation)
                                                    .providedInternalImeInsets);
                                        }
                                        : null;
                                        : null;
                        switch (insetsType) {
                        switch (insetsType) {
                            case ITYPE_STATUS_BAR:
                            case ITYPE_STATUS_BAR:
@@ -1201,10 +1204,9 @@ public class DisplayPolicy {
                                break;
                                break;
                        }
                        }
                        mDisplayContent.setInsetProvider(insetsType, win, (displayFrames,
                        mDisplayContent.setInsetProvider(insetsType, win, (displayFrames,
                                windowState, inOutFrame) -> {
                                windowContainer, inOutFrame) -> {
                            inOutFrame.inset(
                            inOutFrame.inset(win.getLayoutingAttrs(
                                    windowState.getLayoutingAttrs(displayFrames.mRotation)
                                    displayFrames.mRotation).providedInternalInsets);
                                            .providedInternalInsets);
                            inOutFrame.inset(win.mGivenContentInsets);
                            inOutFrame.inset(win.mGivenContentInsets);
                        }, imeFrameProvider);
                        }, imeFrameProvider);
                        mInsetsSourceWindowsExceptIme.add(win);
                        mInsetsSourceWindowsExceptIme.add(win);
@@ -1230,8 +1232,13 @@ public class DisplayPolicy {
        }
        }
    }
    }


    TriConsumer<DisplayFrames, WindowState, Rect> getImeSourceFrameProvider() {
    TriConsumer<DisplayFrames, WindowContainer, Rect> getImeSourceFrameProvider() {
        return (displayFrames, windowState, inOutFrame) -> {
        return (displayFrames, windowContainer, inOutFrame) -> {
            WindowState windowState = windowContainer.asWindowState();
            if (windowState == null) {
                throw new IllegalArgumentException("IME insets must be provided by a window.");
            }

            if (mNavigationBar != null && navigationBarPosition(displayFrames.mRotation)
            if (mNavigationBar != null && navigationBarPosition(displayFrames.mRotation)
                    == NAV_BAR_BOTTOM) {
                    == NAV_BAR_BOTTOM) {
                // In gesture navigation, nav bar frame is larger than frame to calculate insets.
                // In gesture navigation, nav bar frame is larger than frame to calculate insets.
+11 −5
Original line number Original line Diff line number Diff line
@@ -113,8 +113,8 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    private void reportImeDrawnForOrganizer(InsetsControlTarget caller) {
    private void reportImeDrawnForOrganizer(InsetsControlTarget caller) {
        if (caller.getWindow() != null && caller.getWindow().getTask() != null) {
        if (caller.getWindow() != null && caller.getWindow().getTask() != null) {
            if (caller.getWindow().getTask().isOrganized()) {
            if (caller.getWindow().getTask().isOrganized()) {
                mWin.mWmService.mAtmService.mTaskOrganizerController.reportImeDrawnOnTask(
                mWindowContainer.mWmService.mAtmService.mTaskOrganizerController
                        caller.getWindow().getTask());
                        .reportImeDrawnOnTask(caller.getWindow().getTask());
            }
            }
        }
        }
    }
    }
@@ -173,12 +173,18 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    }
    }


    void checkShowImePostLayout() {
    void checkShowImePostLayout() {
        if (mWindowContainer == null) {
            return;
        }
        WindowState windowState =  mWindowContainer.asWindowState();
        if (windowState == null) {
            throw new IllegalArgumentException("IME insets must be provided by a window.");
        }
        // check if IME is drawn
        // check if IME is drawn
        if (mIsImeLayoutDrawn
        if (mIsImeLayoutDrawn
                || (isReadyToShowIme()
                || (isReadyToShowIme()
                && mWin != null
                && windowState.isDrawn()
                && mWin.isDrawn()
                && !windowState.mGivenInsetsPending)) {
                && !mWin.mGivenInsetsPending)) {
            mIsImeLayoutDrawn = true;
            mIsImeLayoutDrawn = true;
            // show IME if InputMethodService requested it to be shown.
            // show IME if InputMethodService requested it to be shown.
            if (mShowImeRunner != null) {
            if (mShowImeRunner != null) {
+3 −2
Original line number Original line Diff line number Diff line
@@ -177,7 +177,8 @@ class InsetsPolicy {


    boolean isHidden(@InternalInsetsType int type) {
    boolean isHidden(@InternalInsetsType int type) {
        final InsetsSourceProvider provider =  mStateController.peekSourceProvider(type);
        final InsetsSourceProvider provider =  mStateController.peekSourceProvider(type);
        return provider != null && provider.hasWindow() && !provider.getSource().isVisible();
        return provider != null && provider.hasWindowContainer()
                && !provider.getSource().isVisible();
    }
    }


    void showTransient(@InternalInsetsType int[] types, boolean isGestureOnSystemBar) {
    void showTransient(@InternalInsetsType int[] types, boolean isGestureOnSystemBar) {
+108 −72

File changed.

Preview size limit exceeded, changes collapsed.

Loading