From 4c0c6a87c0c8fe82a3300c3bccac3ee621619cca Mon Sep 17 00:00:00 2001 From: Sandro Meier Date: Thu, 5 Jan 2023 14:04:14 +0000 Subject: [PATCH] Align moving display to top behavior The behavior of moving a display to top was different based on perDisplayFocusEnabled. In the perDisplayFocusEnabled=true case only a tap on the screen, but not a targeted key would move the display to the top. To simplify the logic this change makes the behavior the same for both cases: A targeted key, as well as a touch on a display moves that display to top. See also b/121057974, which introduced the behavior. Note that this change does not affect the window focus behavior. Displays have a window focus anyway with perDisplayFocusEnabled=true. Note that the behavior for perDisplayFocusEnabled=false stays unchanged. Bug: 254161477 Test: atest "CtsWindowManagerDeviceTestCases:android.server.wm.WindowFocusTests" Test: atest "CtsWindowManagerDeviceTestCases:android.server.wm.MultiDisplayPolicyTests" Change-Id: I52467f028b012ac2abdcb1838d4752e5e4bc4693 --- .../com/android/server/wm/WindowManagerService.java | 11 ++--------- .../core/java/com/android/server/wm/WindowState.java | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 87670969aae65..bded45e01a99d 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -3174,7 +3174,8 @@ public class WindowManagerService extends IWindowManager.Stub /** * Moves the given display to the top. If it cannot be moved to the top this method does - * nothing. + * nothing (e.g. if the display has the flag FLAG_STEAL_TOP_FOCUS_DISABLED set). + * @param displayId The display to move to the top. */ void moveDisplayToTopInternal(int displayId) { synchronized (mGlobalLock) { @@ -3189,14 +3190,6 @@ public class WindowManagerService extends IWindowManager.Stub return; } - if (mPerDisplayFocusEnabled) { - ProtoLog.i(WM_DEBUG_FOCUS_LIGHT, - "Not moving display (displayId=%d) to top. Top focused displayId=%d. " - + "Reason: config_perDisplayFocusEnabled", displayId, - mRoot.getTopFocusedDisplayContent().getDisplayId()); - return; - } - // Nothing prevented us from moving the display to the top. Let's do it! displayContent.getParent().positionChildAt(WindowContainer.POSITION_TOP, displayContent, true /* includingParents */); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 223352e32f9f4..33af563bd9543 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -6241,7 +6241,6 @@ class WindowState extends WindowContainer implements WindowManagerP @Override public void handleTapOutsideFocusInsideSelf() { - final DisplayContent displayContent = getDisplayContent(); mWmService.moveDisplayToTopInternal(getDisplayId()); mWmService.handleTaskFocusChange(getTask(), mActivityRecord); }