Transfer focus from the current focused window for two-finger scroll
When doing the two-finger scroll, we resize based on the main window.
However, the main window might not have focus (eg. diaglog displayed
on top). We need to grab focus from the window that actually has focus.
bug: 26604036
Change-Id: I05d0ed95c59901c925e242d4b9a856d1ca0a55f3
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index e7aba6d..fdc9604 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -7267,8 +7267,18 @@
mTaskPositioner = new TaskPositioner(this);
mTaskPositioner.register(display);
mInputMonitor.updateInputWindowsLw(true /*force*/);
+
+ // We need to grab the touch focus so that the touch events during the
+ // resizing/scrolling are not sent to the app. 'win' is the main window
+ // of the app, it may not have focus since there might be other windows
+ // on top (eg. a dialog window).
+ WindowState transferFocusFromWin = win;
+ if (mCurrentFocus != null && mCurrentFocus != win
+ && mCurrentFocus.mAppToken == win.mAppToken) {
+ transferFocusFromWin = mCurrentFocus;
+ }
if (!mInputManager.transferTouchFocus(
- win.mInputChannel, mTaskPositioner.mServerChannel)) {
+ transferFocusFromWin.mInputChannel, mTaskPositioner.mServerChannel)) {
Slog.e(TAG_WM, "startPositioningLocked: Unable to transfer touch focus");
mTaskPositioner.unregister();
mTaskPositioner = null;