@@ -324,6 +324,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
324324 volatile boolean mPowerKeyHandled ; // accessed from input reader and handler thread
325325 boolean mPendingPowerKeyUpCanceled ;
326326 Handler mHandler ;
327+ WindowState mLastInputMethodWindow = null ;
328+ WindowState mLastInputMethodTargetWindow = null ;
327329
328330 static final int RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS = 0 ;
329331 static final int RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW = 1 ;
@@ -2395,6 +2397,14 @@ public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
23952397 if (win == mStatusBar || win == mNavigationBar ) {
23962398 return ;
23972399 }
2400+ final boolean needsToOffsetInputMethodTarget =
2401+ (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null );
2402+ if (needsToOffsetInputMethodTarget ) {
2403+ if (DEBUG_LAYOUT ) {
2404+ Slog .i (TAG , "Offset ime target window by the last ime window state" );
2405+ }
2406+ offsetInputMethodWindowLw (mLastInputMethodWindow );
2407+ }
23982408
23992409 final int fl = attrs .flags ;
24002410 final int sim = attrs .softInputMode ;
@@ -2672,22 +2682,27 @@ public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,
26722682 // Dock windows carve out the bottom of the screen, so normal windows
26732683 // can't appear underneath them.
26742684 if (attrs .type == TYPE_INPUT_METHOD && !win .getGivenInsetsPendingLw ()) {
2675- int top = win .getContentFrameLw ().top ;
2676- top += win .getGivenContentInsetsLw ().top ;
2677- if (mContentBottom > top ) {
2678- mContentBottom = top ;
2679- }
2680- top = win .getVisibleFrameLw ().top ;
2681- top += win .getGivenVisibleInsetsLw ().top ;
2682- if (mCurBottom > top ) {
2683- mCurBottom = top ;
2684- }
2685- if (DEBUG_LAYOUT ) Log .v (TAG , "Input method: mDockBottom="
2686- + mDockBottom + " mContentBottom="
2687- + mContentBottom + " mCurBottom=" + mCurBottom );
2685+ setLastInputMethodWindowLw (null , null );
2686+ offsetInputMethodWindowLw (win );
26882687 }
26892688 }
26902689
2690+ private void offsetInputMethodWindowLw (WindowState win ) {
2691+ int top = win .getContentFrameLw ().top ;
2692+ top += win .getGivenContentInsetsLw ().top ;
2693+ if (mContentBottom > top ) {
2694+ mContentBottom = top ;
2695+ }
2696+ top = win .getVisibleFrameLw ().top ;
2697+ top += win .getGivenVisibleInsetsLw ().top ;
2698+ if (mCurBottom > top ) {
2699+ mCurBottom = top ;
2700+ }
2701+ if (DEBUG_LAYOUT ) Log .v (TAG , "Input method: mDockBottom="
2702+ + mDockBottom + " mContentBottom="
2703+ + mContentBottom + " mCurBottom=" + mCurBottom );
2704+ }
2705+
26912706 /** {@inheritDoc} */
26922707 @ Override
26932708 public void finishLayoutLw () {
@@ -4184,6 +4199,12 @@ public boolean hasNavigationBar() {
41844199 return mHasNavigationBar ;
41854200 }
41864201
4202+ @ Override
4203+ public void setLastInputMethodWindowLw (WindowState ime , WindowState target ) {
4204+ mLastInputMethodWindow = ime ;
4205+ mLastInputMethodTargetWindow = target ;
4206+ }
4207+
41874208 public void dump (String prefix , FileDescriptor fd , PrintWriter pw , String [] args ) {
41884209 pw .print (prefix ); pw .print ("mSafeMode=" ); pw .print (mSafeMode );
41894210 pw .print (" mSystemReady=" ); pw .print (mSystemReady );
0 commit comments