summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTiger Huang <tigerhuang@google.com>2018-12-11 20:24:51 +0800
committerTiger Huang <tigerhuang@google.com>2018-12-15 16:30:14 +0800
commit51c5a1d0429baf5d508dc287c12f52a5a0bc5135 (patch)
tree678638cd3c1d51417f1925947d8c73c0ca1c8c4d /core/java
parent3c2a2034e4890703dcfa3f61f8c5d6daa30de90e (diff)
Make per-display focus optional (1/2)
In general cases, we don't have multiple input methods simultaneously. So that it may not make sense to have multiple focused window in the system. Especially when there are multiple blinking cursors of input boxes on different displays, the user may not be able to know which input box can receive key events. In these cases, we let the system has only one focused window. In some cases, there can be multiple input methods simultaneously (one for each display). To enable multiple users to interact with the corresponding displays at the same time, we should let the system have per-display focused window in these cases. This CL makes per-display focus optional, and also reverts ag/5312657 Fix: 120241480 Fix: 120790099 Test: atest ActivityManagerMultiDisplayTests \ CtsWindowManagerDeviceTestCases \ WmTests Change-Id: Ie030eed523599b217060887171710692d050e5d8
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/IWindow.aidl35
-rw-r--r--core/java/android/view/ViewRootImpl.java33
-rw-r--r--core/java/com/android/internal/view/BaseIWindow.java4
3 files changed, 17 insertions, 55 deletions
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index 5e6d3d19fa2f..c06a1fe0a257 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -71,41 +71,18 @@ oneway interface IWindow {
void dispatchGetNewSurface();
/**
- * Tell the window that it is either gaining or losing focus.
- *
- * @param hasFocus {@code true} if window has focus, {@code false} otherwise.
- * @param inTouchMode {@code true} if screen is in touch mode, {@code false} otherwise.
- * @param reportToClient {@code true} when need to report to child view with
- * {@link View#onWindowFocusChanged(boolean)}, {@code false} otherwise.
- * <p>
- * Note: In the previous design, there is only one window focus state tracked by
- * WindowManagerService.
- * For multi-display, the window focus state is tracked by each display independently.
- * <p>
- * It will introduce a problem if the window was already focused on one display and then
- * switched to another display, since the window focus state on each display is independent,
- * there is no global window focus state in WindowManagerService, so the window focus state of
- * the former display remains unchanged.
- * <p>
- * When switched back to former display, some flows that rely on the global window focus state
- * in view root will be missed due to the window focus state remaining unchanged.
- * (i.e: Showing single IME window when switching between displays.)
- * <p>
- * To solve the problem, WindowManagerService tracks the top focused display change and then
- * callbacks to the client via this method to make sure that the client side will request the
- * IME on the top focused display, and then set {@param reportToClient} as {@code false} to
- * ignore reporting to the application, since its focus remains unchanged on its display.
- *
+ * Tell the window that it is either gaining or losing focus. Keep it up
+ * to date on the current state showing navigational focus (touch mode) too.
*/
- void windowFocusChanged(boolean hasFocus, boolean inTouchMode, boolean reportToClient);
-
+ void windowFocusChanged(boolean hasFocus, boolean inTouchMode);
+
void closeSystemDialogs(String reason);
-
+
/**
* Called for wallpaper windows when their offsets change.
*/
void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync);
-
+
void dispatchWallpaperCommand(String action, int x, int y,
int z, in Bundle extras, boolean sync);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index e36e2588f3d7..4b97fbeafa0c 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2741,7 +2741,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
- private void handleWindowFocusChanged(boolean reportToClient) {
+ private void handleWindowFocusChanged() {
final boolean hasWindowFocus;
final boolean inTouchMode;
synchronized (this) {
@@ -2776,9 +2776,8 @@ public final class ViewRootImpl implements ViewParent,
} catch (RemoteException ex) {
}
// Retry in a bit.
- final Message msg = mHandler.obtainMessage(MSG_WINDOW_FOCUS_CHANGED);
- msg.arg1 = reportToClient ? 1 : 0;
- mHandler.sendMessageDelayed(msg, 500);
+ mHandler.sendMessageDelayed(mHandler.obtainMessage(
+ MSG_WINDOW_FOCUS_CHANGED), 500);
return;
}
}
@@ -2795,15 +2794,8 @@ public final class ViewRootImpl implements ViewParent,
}
if (mView != null) {
mAttachInfo.mKeyDispatchState.reset();
- // We dispatch onWindowFocusChanged to child view only when window is gaining /
- // losing focus.
- // If the focus is updated from top display change but window focus on the display
- // remains unchanged, will not callback onWindowFocusChanged again since it may
- // be redundant & can affect the state when it callbacks.
- if (reportToClient) {
- mView.dispatchWindowFocusChanged(hasWindowFocus);
- mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus);
- }
+ mView.dispatchWindowFocusChanged(hasWindowFocus);
+ mAttachInfo.mTreeObserver.dispatchOnWindowFocusChange(hasWindowFocus);
if (mAttachInfo.mTooltipHost != null) {
mAttachInfo.mTooltipHost.hideTooltip();
}
@@ -4404,7 +4396,7 @@ public final class ViewRootImpl implements ViewParent,
}
break;
case MSG_WINDOW_FOCUS_CHANGED: {
- handleWindowFocusChanged(msg.arg1 != 0 /* reportToClient */);
+ handleWindowFocusChanged();
} break;
case MSG_DIE:
doDie();
@@ -7348,7 +7340,7 @@ public final class ViewRootImpl implements ViewParent,
}
if (stage != null) {
- handleWindowFocusChanged(true /* reportToClient */);
+ handleWindowFocusChanged();
stage.deliver(q);
} else {
finishInputEvent(q);
@@ -7665,11 +7657,6 @@ public final class ViewRootImpl implements ViewParent,
}
public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) {
- windowFocusChanged(hasFocus, inTouchMode, true /* reportToClient */);
- }
-
- public void windowFocusChanged(boolean hasFocus, boolean inTouchMode,
- boolean reportToClient) {
synchronized (this) {
mWindowFocusChanged = true;
mUpcomingWindowFocus = hasFocus;
@@ -7677,7 +7664,6 @@ public final class ViewRootImpl implements ViewParent,
}
Message msg = Message.obtain();
msg.what = MSG_WINDOW_FOCUS_CHANGED;
- msg.arg1 = reportToClient ? 1 : 0;
mHandler.sendMessage(msg);
}
@@ -8239,11 +8225,10 @@ public final class ViewRootImpl implements ViewParent,
}
@Override
- public void windowFocusChanged(boolean hasFocus, boolean inTouchMode,
- boolean reportToClient) {
+ public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
- viewAncestor.windowFocusChanged(hasFocus, inTouchMode, reportToClient);
+ viewAncestor.windowFocusChanged(hasFocus, inTouchMode);
}
}
diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java
index c8834a889333..ae5c67df8f1e 100644
--- a/core/java/com/android/internal/view/BaseIWindow.java
+++ b/core/java/com/android/internal/view/BaseIWindow.java
@@ -26,9 +26,9 @@ import android.view.DisplayCutout;
import android.view.DragEvent;
import android.view.IWindow;
import android.view.IWindowSession;
-import android.view.PointerIcon;
import android.view.InsetsSourceControl;
import android.view.InsetsState;
+import android.view.PointerIcon;
import com.android.internal.os.IResultReceiver;
@@ -76,7 +76,7 @@ public class BaseIWindow extends IWindow.Stub {
}
@Override
- public void windowFocusChanged(boolean hasFocus, boolean touchEnabled, boolean reportToClient) {
+ public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) {
}
@Override