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

Commit f54a2f3e authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "DisplayImeController: reapply visibility when leash changes" into rvc-qpr-dev

parents a3082277 f5566bdb
Loading
Loading
Loading
Loading
+45 −5
Original line number Diff line number Diff line
@@ -228,19 +228,43 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                        mHandler.post(() -> {
                            final Point lastSurfacePosition = mImeSourceControl != null
                                    ? mImeSourceControl.getSurfacePosition() : null;
                            final boolean positionChanged =
                                    !activeControl.getSurfacePosition().equals(lastSurfacePosition);
                            final boolean leashChanged =
                                    !haveSameLeash(mImeSourceControl, activeControl);
                            mImeSourceControl = activeControl;
                            if (!activeControl.getSurfacePosition().equals(lastSurfacePosition)
                                    && mAnimation != null) {
                            if (mAnimation != null) {
                                if (positionChanged) {
                                    startAnimation(mImeShowing, true /* forceRestart */);
                            } else if (!mImeShowing) {
                                }
                            } else {
                                if (leashChanged) {
                                    applyVisibilityToLeash();
                                }
                                if (!mImeShowing) {
                                    removeImeSurface();
                                }
                            }
                        });
                    }
                }
            }
        }

        private void applyVisibilityToLeash() {
            SurfaceControl leash = mImeSourceControl.getLeash();
            if (leash != null) {
                SurfaceControl.Transaction t = mTransactionPool.acquire();
                if (mImeShowing) {
                    t.show(leash);
                } else {
                    t.hide(leash);
                }
                t.apply();
                mTransactionPool.release(t);
            }
        }

        @Override
        public void showInsets(int types, boolean fromIme) {
            if ((types & WindowInsets.Type.ime()) == 0) {
@@ -492,4 +516,20 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
        return IInputMethodManager.Stub.asInterface(
                ServiceManager.getService(Context.INPUT_METHOD_SERVICE));
    }

    private static boolean haveSameLeash(InsetsSourceControl a, InsetsSourceControl b) {
        if (a == b) {
            return true;
        }
        if (a == null || b == null) {
            return false;
        }
        if (a.getLeash() == b.getLeash()) {
            return true;
        }
        if (a.getLeash() == null || b.getLeash() == null) {
            return false;
        }
        return a.getLeash().isSameSurface(b.getLeash());
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -6187,7 +6187,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            if (inputMethodControlTarget != null) {
                pw.print("  inputMethodControlTarget in display# "); pw.print(displayId);
                pw.print(' '); pw.println(inputMethodControlTarget.getWindow());
                pw.print(' '); pw.println(inputMethodControlTarget);
            }
        });
        pw.print("  mInTouchMode="); pw.println(mInTouchMode);