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

Commit c277a8e2 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Fix IME visibleTopInsets before showWindow

In [1] we started setting the IME's reported visibleTopInsets to 0
before we get a showWindow call. This was meant to set the IME source
visible frame as empty/null, and thus disallow user animations on it.
However, in [2] we reverted this to always allow (IME) insets sources to
be user-controllable, even when no insets are provided, to enable
controlling the alpha of the IME window for floating IME mode.

Moreover, setting the visibleTopInsets essentially signals that the
visibile insets providing frame of the IME stretches out to the top of
the decor view, which is incorrect. This approach worked as
InsetsSourceProvider#updateSourceFrame had a special case which set the
visibleFrame to null when the givenVisibleInsets are 0 on all sides.
However, this is brittle, as any other source of visible insets setting
a different side to a non-zero value can break this.

This removes setting the visibleTopInsets to 0, instead falling back
to the value from onComputeInsets, which would be the full decorView
height when called before showWindow, to signal that there are no
visible insets reported.

  [1]: Id70f59be7653beedc02d6c8bc3b1bd50a357f4fe
  [2]: I3210df9bcc087f5fba712e0e7ac4922475c3b88d

Flag: EXEMPT bugfix
Test: atest ImeInsetsControllerTest
Bug: 407043224
Change-Id: I320ecca9ef5d9c865d6add500a036a3ccd882aa9
parent bfe2c0c9
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -734,10 +734,6 @@ public class InputMethodService extends AbstractInputMethodService {
    final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> {
        onComputeInsets(mTmpInsets);
        mNavigationBarController.updateInsets(mTmpInsets);
        if (!mViewsCreated) {
            // The IME views are not ready, keep visible insets untouched.
            mTmpInsets.visibleTopInsets = 0;
        }
        if (isExtractViewShown()) {
            // In true fullscreen mode, we just say the window isn't covering
            // any content so we don't impact whatever is behind.
@@ -754,6 +750,8 @@ public class InputMethodService extends AbstractInputMethodService {
        mNavigationBarController.updateTouchableInsets(mTmpInsets, info);

        if (mInputFrame != null) {
            // info.visibleInsets is the decor view height in full screen mode. Instead, use the
            // visibleTopInsets here to correctly set exclusion rect for full screen IMEs.
            setImeExclusionRect(mTmpInsets.visibleTopInsets);
        }
    };