Skip to content

Commit 2033763

Browse files
author
Jeff Brown
committed
Allow a window on a secondary display to have focus.
If any window on the default display has focus, then it gets focus as usual. If no window on the default display has focus, then we consider windows on the secondary display. In the future we will need more elaborate schemes for managing focus across multiple displays, but this is enough for testing purposes now. Bug: 7183618 Change-Id: I21ddb9904eb9e574e42d28743aeca51f4ffebf64
1 parent efd43bd commit 2033763

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9777,7 +9777,7 @@ private boolean updateFocusedWindowLocked(int mode, boolean updateInputWindows)
97779777
if (moveInputMethodWindowsIfNeededLocked(
97789778
mode != UPDATE_FOCUS_WILL_ASSIGN_LAYERS &&
97799779
mode != UPDATE_FOCUS_WILL_PLACE_SURFACES)) {
9780-
getDefaultDisplayContentLocked().layoutNeeded = true;
9780+
displayContent.layoutNeeded = true;
97819781
}
97829782
if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
97839783
performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows);
@@ -9791,7 +9791,7 @@ private boolean updateFocusedWindowLocked(int mode, boolean updateInputWindows)
97919791

97929792
if ((focusChanged & WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT) != 0) {
97939793
// The change in focus caused us to need to do a layout. Okay.
9794-
getDefaultDisplayContentLocked().layoutNeeded = true;
9794+
displayContent.layoutNeeded = true;
97959795
if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
97969796
performLayoutLockedInner(displayContent, true /*initial*/, updateInputWindows);
97979797
}
@@ -9814,22 +9814,29 @@ private void finishUpdateFocusedWindowAfterAssignLayersLocked(boolean updateInpu
98149814
}
98159815

98169816
private WindowState computeFocusedWindowLocked() {
9817-
WindowState result = null;
9818-
WindowState win;
9819-
98209817
if (mAnimator.mUniverseBackground != null
98219818
&& mAnimator.mUniverseBackground.mWin.canReceiveKeys()) {
98229819
return mAnimator.mUniverseBackground.mWin;
98239820
}
98249821

9822+
final int displayCount = mDisplayContents.size();
9823+
for (int i = 0; i < displayCount; i++) {
9824+
final DisplayContent displayContent = mDisplayContents.valueAt(i);
9825+
WindowState win = findFocusedWindowLocked(displayContent);
9826+
if (win != null) {
9827+
return win;
9828+
}
9829+
}
9830+
return null;
9831+
}
9832+
9833+
private WindowState findFocusedWindowLocked(DisplayContent displayContent) {
98259834
int nextAppIndex = mAppTokens.size()-1;
9826-
WindowToken nextApp = nextAppIndex >= 0
9827-
? mAppTokens.get(nextAppIndex) : null;
9835+
WindowToken nextApp = nextAppIndex >= 0 ? mAppTokens.get(nextAppIndex) : null;
98289836

9829-
// TODO(multidisplay): IMEs are only supported on the default display.
9830-
WindowList windows = getDefaultWindowListLocked();
9837+
final WindowList windows = displayContent.getWindowList();
98319838
for (int i = windows.size() - 1; i >= 0; i--) {
9832-
win = windows.get(i);
9839+
final WindowState win = windows.get(i);
98339840

98349841
if (localLOGV || DEBUG_FOCUS) Slog.v(
98359842
TAG, "Looking for focus: " + i
@@ -9879,12 +9886,10 @@ private WindowState computeFocusedWindowLocked() {
98799886
if (win.canReceiveKeys()) {
98809887
if (DEBUG_FOCUS) Slog.v(
98819888
TAG, "Found focus @ " + i + " = " + win);
9882-
result = win;
9883-
break;
9889+
return win;
98849890
}
98859891
}
9886-
9887-
return result;
9892+
return null;
98889893
}
98899894

98909895
private void startFreezingDisplayLocked(boolean inTransaction,

0 commit comments

Comments
 (0)