Merge "Handle focused tasks on multiple displays"
This commit is contained in:
committed by
Android (Google) Code Review
commit
dfabcb1ca0
@@ -2031,6 +2031,8 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
return runTaskDragTaskTest(pw);
|
||||
} else if (op.equals("size-task-test")) {
|
||||
return runTaskSizeTaskTest(pw);
|
||||
} else if (op.equals("focus")) {
|
||||
return runTaskFocus(pw);
|
||||
} else {
|
||||
getErrPrintWriter().println("Error: unknown command '" + op + "'");
|
||||
return -1;
|
||||
@@ -2322,6 +2324,13 @@ final class ActivityManagerShellCommand extends ShellCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runTaskFocus(PrintWriter pw) throws RemoteException {
|
||||
final int taskId = Integer.parseInt(getNextArgRequired());
|
||||
pw.println("Setting focus to task " + taskId);
|
||||
mInterface.setFocusedTask(taskId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int runWrite(PrintWriter pw) {
|
||||
mInternal.enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
|
||||
"registerUidObserver()");
|
||||
|
||||
@@ -1072,19 +1072,25 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
||||
}
|
||||
|
||||
void setTouchExcludeRegion(Task focusedTask) {
|
||||
mTouchExcludeRegion.set(mBaseDisplayRect);
|
||||
final int delta = dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics);
|
||||
mTmpRect2.setEmpty();
|
||||
for (int stackNdx = mTaskStackContainers.size() - 1; stackNdx >= 0; --stackNdx) {
|
||||
final TaskStack stack = mTaskStackContainers.get(stackNdx);
|
||||
stack.setTouchExcludeRegion(
|
||||
focusedTask, delta, mTouchExcludeRegion, mContentRect, mTmpRect2);
|
||||
}
|
||||
// If we removed the focused task above, add it back and only leave its
|
||||
// outside touch area in the exclusion. TapDectector is not interested in
|
||||
// any touch inside the focused task itself.
|
||||
if (!mTmpRect2.isEmpty()) {
|
||||
mTouchExcludeRegion.op(mTmpRect2, Region.Op.UNION);
|
||||
// The provided task is the task on this display with focus, so if WindowManagerService's
|
||||
// focused app is not on this display, focusedTask will be null.
|
||||
if (focusedTask == null) {
|
||||
mTouchExcludeRegion.setEmpty();
|
||||
} else {
|
||||
mTouchExcludeRegion.set(mBaseDisplayRect);
|
||||
final int delta = dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics);
|
||||
mTmpRect2.setEmpty();
|
||||
for (int stackNdx = mTaskStackContainers.size() - 1; stackNdx >= 0; --stackNdx) {
|
||||
final TaskStack stack = mTaskStackContainers.get(stackNdx);
|
||||
stack.setTouchExcludeRegion(
|
||||
focusedTask, delta, mTouchExcludeRegion, mContentRect, mTmpRect2);
|
||||
}
|
||||
// If we removed the focused task above, add it back and only leave its
|
||||
// outside touch area in the exclusion. TapDectector is not interested in
|
||||
// any touch inside the focused task itself.
|
||||
if (!mTmpRect2.isEmpty()) {
|
||||
mTouchExcludeRegion.op(mTmpRect2, Region.Op.UNION);
|
||||
}
|
||||
}
|
||||
final WindowState inputMethod = mService.mInputMethodWindow;
|
||||
if (inputMethod != null && inputMethod.isVisibleLw()) {
|
||||
|
||||
@@ -784,7 +784,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
|
||||
if (updateInputWindowsNeeded) {
|
||||
mService.mInputMonitor.updateInputWindowsLw(false /*force*/);
|
||||
}
|
||||
mService.setFocusTaskRegionLocked();
|
||||
mService.setFocusTaskRegionLocked(null);
|
||||
|
||||
// Check to see if we are now in a state where the screen should
|
||||
// be enabled, because the window obscured flags have changed.
|
||||
|
||||
@@ -2586,13 +2586,18 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
void setFocusTaskRegionLocked() {
|
||||
void setFocusTaskRegionLocked(AppWindowToken previousFocus) {
|
||||
final Task focusedTask = mFocusedApp != null ? mFocusedApp.mTask : null;
|
||||
if (focusedTask != null) {
|
||||
final DisplayContent displayContent = focusedTask.getDisplayContent();
|
||||
if (displayContent != null) {
|
||||
displayContent.setTouchExcludeRegion(focusedTask);
|
||||
}
|
||||
final Task previousTask = previousFocus != null ? previousFocus.mTask : null;
|
||||
final DisplayContent focusedDisplayContent =
|
||||
focusedTask != null ? focusedTask.getDisplayContent() : null;
|
||||
final DisplayContent previousDisplayContent =
|
||||
previousTask != null ? previousTask.getDisplayContent() : null;
|
||||
if (previousDisplayContent != null && previousDisplayContent != focusedDisplayContent) {
|
||||
previousDisplayContent.setTouchExcludeRegion(null);
|
||||
}
|
||||
if (focusedDisplayContent != null) {
|
||||
focusedDisplayContent.setTouchExcludeRegion(focusedTask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2618,9 +2623,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
|
||||
final boolean changed = mFocusedApp != newFocus;
|
||||
if (changed) {
|
||||
AppWindowToken prev = mFocusedApp;
|
||||
mFocusedApp = newFocus;
|
||||
mInputMonitor.setFocusedAppLw(newFocus);
|
||||
setFocusTaskRegionLocked();
|
||||
setFocusTaskRegionLocked(prev);
|
||||
}
|
||||
|
||||
if (moveFocusNow && changed) {
|
||||
@@ -7456,7 +7462,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
synchronized (mWindowMap) {
|
||||
getDefaultDisplayContentLocked().getDockedDividerController()
|
||||
.setTouchRegion(touchRegion);
|
||||
setFocusTaskRegionLocked();
|
||||
setFocusTaskRegionLocked(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user