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

Commit 0dab5e84 authored by Felix Stern's avatar Felix Stern
Browse files

Only apply IME insets to the floating window that has focus

In desktop windowing mode: When there were several windows of the same app with dialogs open, and one was showing the IME, the insets were applied to all of the windows/dialogs. Although, only the IME input target should receive them. This CL fixes that by checking if the current target is the IME input target and has the IME also requested to be visible.

Test: Open desktop windowing mode (two windows with dialogs open); show/hide IME on one dialog
Fix: 368444466
Flag: android.view.inputmethod.refactor_insets_controller
Change-Id: Id376f73b7c3b0315834e9be4eecc21a826db85fc
parent d8dacaf6
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -258,16 +258,13 @@ class InsetsPolicy {
     * We also need to exclude certain types of insets source for client within specific windowing
     * modes.
     *
     * @param attrs the LayoutParams of the target
     * @param windowingMode the windowing mode of the target
     * @param isAlwaysOnTop is the target always on top
     * @param target the target on which the policy is applied
     * @param state the input inset state containing all the sources
     * @return The state stripped of the necessary information.
     */
    InsetsState enforceInsetsPolicyForTarget(WindowManager.LayoutParams attrs,
            @WindowConfiguration.WindowingMode int windowingMode, boolean isAlwaysOnTop,
            InsetsState state) {
    InsetsState enforceInsetsPolicyForTarget(WindowState target, InsetsState state) {
        final InsetsState originalState = state;
        final WindowManager.LayoutParams attrs = target.getAttrs();

        // The caller should not receive the visible insets provided by itself.
        if (attrs.type == TYPE_INPUT_METHOD) {
@@ -316,13 +313,18 @@ class InsetsPolicy {
            }
        }

        final @WindowConfiguration.WindowingMode int windowingMode = target.getWindowingMode();
        if (WindowConfiguration.isFloating(windowingMode)
                || (windowingMode == WINDOWING_MODE_MULTI_WINDOW && isAlwaysOnTop)) {
                || (windowingMode == WINDOWING_MODE_MULTI_WINDOW && target.isAlwaysOnTop())) {
            // Keep frames, caption, and IME.
            int types = WindowInsets.Type.captionBar();
            if (windowingMode != WINDOWING_MODE_PINNED) {
                if (!Flags.refactorInsetsController() || (mDisplayContent != null
                        && target == mDisplayContent.getImeInputTarget()
                        && (WindowInsets.Type.ime() & target.getRequestedVisibleTypes()) != 0)) {
                    types |= WindowInsets.Type.ime();
                }
            }
            final InsetsState newState = new InsetsState();
            newState.set(state, types);
            state = newState;
+2 −2
Original line number Diff line number Diff line
@@ -1631,8 +1631,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
        final InsetsState rawInsetsState =
                mFrozenInsetsState != null ? mFrozenInsetsState : getMergedInsetsState();
        final InsetsState insetsStateForWindow = insetsPolicy.enforceInsetsPolicyForTarget(
                mAttrs, getWindowingMode(), isAlwaysOnTop(), rawInsetsState);
        final InsetsState insetsStateForWindow = insetsPolicy.enforceInsetsPolicyForTarget(this,
                rawInsetsState);
        return insetsPolicy.adjustInsetsForWindow(this, insetsStateForWindow,
                includeTransient);
    }