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

Commit b8da4a7f authored by Chong Zhang's avatar Chong Zhang
Browse files

Use focused app's stack for IME adjustment

Don't use mInputMethodTarget as it could be set to some system alert
window that has both FLAG_NOT_FOCUSABLE and FLAG_ALT_FOCUSABLE_IM,
and it's not actually taking inputs.

bug: 28328085
Change-Id: I38263f64fec13a5e10357499ebc97671389ba69a
parent 53c33d97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1089,7 +1089,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
        }
        setAdjustedBounds(mTmpAdjustedBounds);

        final boolean isImeTarget = (mService.getImeTargetStackLocked() == this);
        final boolean isImeTarget = (mService.getImeFocusStackLocked() == this);
        if (mAdjustedForIme && adjust && !isImeTarget) {
            final float alpha = Math.max(mAdjustImeAmount, mAdjustDividerAmount)
                    * IME_ADJUST_DIM_AMOUNT;
+8 −5
Original line number Diff line number Diff line
@@ -7571,7 +7571,7 @@ public class WindowManagerService extends IWindowManager.Stub
        final WindowState imeWin = mInputMethodWindow;
        final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw();
        final boolean dockVisible = isStackVisibleLocked(DOCKED_STACK_ID);
        final TaskStack imeTargetStack = getImeTargetStackLocked();
        final TaskStack imeTargetStack = getImeFocusStackLocked();
        final int imeDockSide = (dockVisible && imeTargetStack != null) ?
                imeTargetStack.getDockSide() : DOCKED_INVALID;
        final boolean imeOnTop = (imeDockSide == DOCKED_TOP);
@@ -7740,10 +7740,13 @@ public class WindowManagerService extends IWindowManager.Stub
        return mCurrentFocus;
    }

    TaskStack getImeTargetStackLocked() {
        // Don't use WindowState.getStack() because it returns home stack for system windows.
        Task imeTask = mInputMethodTarget != null ? mInputMethodTarget.getTask() : null;
        return imeTask != null ? imeTask.mStack : null;
    TaskStack getImeFocusStackLocked() {
        // Don't use mCurrentFocus.getStack() because it returns home stack for system windows.
        // Also don't use mInputMethodTarget's stack, because some window with FLAG_NOT_FOCUSABLE
        // and FLAG_ALT_FOCUSABLE_IM flags both set might be set to IME target so they're moved
        // to make room for IME, but the window is not the focused window that's taking input.
        return (mFocusedApp != null && mFocusedApp.mTask != null) ?
                mFocusedApp.mTask.mStack : null;
    }

    private void showAuditSafeModeNotification() {