Skip to content

Commit e849230

Browse files
satok16Android (Google) Code Review
authored andcommitted
Merge "DO NOT MERGE : Backport I5723f627ce323b0d12b Reduce window resizing during IME transition" into jb-dev
2 parents 39f412d + 1bc0a49 commit e849230

File tree

3 files changed

+45
-13
lines changed

3 files changed

+45
-13
lines changed

core/java/android/view/WindowManagerPolicy.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,13 @@ interface OnKeyguardExitResult {
10991099
*/
11001100
public void stopScreenSaver();
11011101

1102+
/**
1103+
* Set the last used input method window state. This state is used to make IME transition
1104+
* smooth.
1105+
* @hide
1106+
*/
1107+
public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1108+
11021109
/**
11031110
* Print the WindowManagerPolicy's state into the given stream.
11041111
*

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,7 @@ public int addWindow(Session session, IWindow client, int seq,
22622262
boolean imMayMove = true;
22632263

22642264
if (attrs.type == TYPE_INPUT_METHOD) {
2265+
win.mGivenInsetsPending = true;
22652266
mInputMethodWindow = win;
22662267
addInputMethodWindowToListLocked(win);
22672268
imMayMove = false;
@@ -3422,6 +3423,9 @@ public void removeWindowToken(IBinder token) {
34223423
synchronized(mWindowMap) {
34233424
WindowToken wtoken = mTokenMap.remove(token);
34243425
if (wtoken != null) {
3426+
if (wtoken.windowType == TYPE_INPUT_METHOD && mInputMethodWindow != null) {
3427+
mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget);
3428+
}
34253429
boolean delayed = false;
34263430
if (!wtoken.hidden) {
34273431
wtoken.hidden = true;

0 commit comments

Comments
 (0)