Merge "Only switch task focus to window's task that was tapped outside current focus" into qt-dev

This commit is contained in:
Chavi Weingarten
2019-04-05 16:41:43 +00:00
committed by Android (Google) Code Review
4 changed files with 30 additions and 64 deletions

View File

@@ -2361,33 +2361,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
layoutAndAssignWindowLayersIfNeeded();
}
/**
* Used to obtain task ID when user taps on coordinate (x, y) in this display, and outside
* current task in focus.
*
* This returns the task ID of the foremost task at (x, y) if the task is not home. Otherwise it
* returns -1.
*
* @param x horizontal coordinate of the tap position
* @param y vertical coordinate of the tap position
* @return the task ID if a non-home task is found; -1 if not
*/
int taskForTapOutside(int x, int y) {
for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) {
final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx);
if (stack.isActivityTypeHome() && !stack.inMultiWindowMode()) {
// We skip not only home stack, but also everything behind home because user can't
// see them when home stack is isn't in multi-window mode.
break;
}
final int taskId = stack.taskIdFromPoint(x, y);
if (taskId != -1) {
return taskId;
}
}
return -1;
}
/**
* Returns true if the input point is within an app window.
*/

View File

@@ -127,7 +127,6 @@ class TaskPositioningController {
void handleTapOutsideTask(DisplayContent displayContent, int x, int y) {
mHandler.post(() -> {
int taskId = -1;
synchronized (mService.mGlobalLock) {
final Task task = displayContent.findTaskForResizePoint(x, y);
if (task != null) {
@@ -135,15 +134,10 @@ class TaskPositioningController {
task.preserveOrientationOnResize(), x, y)) {
return;
}
taskId = task.mTaskId;
} else {
taskId = displayContent.taskForTapOutside(x, y);
}
}
if (taskId >= 0) {
try {
mActivityManager.setFocusedTask(taskId);
} catch (RemoteException e) {
try {
mActivityManager.setFocusedTask(task.mTaskId);
} catch (RemoteException e) {
}
}
}
});

View File

@@ -1458,31 +1458,6 @@ public class TaskStack extends WindowContainer<Task> implements
return false;
}
int taskIdFromPoint(int x, int y) {
getBounds(mTmpRect);
if (!mTmpRect.contains(x, y) || isAdjustedForMinimizedDockedStack()) {
return -1;
}
for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) {
final Task task = mChildren.get(taskNdx);
final WindowState win = task.getTopVisibleAppMainWindow();
if (win == null) {
continue;
}
// We need to use the task's dim bounds (which is derived from the visible bounds of its
// apps windows) for any touch-related tests. Can't use the task's original bounds
// because it might be adjusted to fit the content frame. For example, the presence of
// the IME adjusting the windows frames when the app window is the IME target.
task.getDimBounds(mTmpRect);
if (mTmpRect.contains(x, y)) {
return task.mTaskId;
}
}
return -1;
}
void findTaskForResizePoint(int x, int y, int delta,
DisplayContent.TaskForResizePointSearchResult results) {
if (!getWindowConfiguration().canResizeTask()) {

View File

@@ -7587,12 +7587,36 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
final DisplayContent displayContent = touchedWindow.getDisplayContent();
handleTaskFocusChange(touchedWindow.getTask());
handleDisplayFocusChange(touchedWindow);
}
private void handleTaskFocusChange(Task task) {
if (task == null) {
return;
}
final TaskStack stack = task.mStack;
// We ignore home stack since we don't want home stack to move to front when touched.
// Specifically, in freeform we don't want tapping on home to cause the freeform apps to go
// behind home. See b/117376413
if (stack.isActivityTypeHome()) {
return;
}
try {
mActivityTaskManager.setFocusedTask(task.mTaskId);
} catch (RemoteException e) {
}
}
private void handleDisplayFocusChange(WindowState window) {
final DisplayContent displayContent = window.getDisplayContent();
if (displayContent == null) {
return;
}
if (!touchedWindow.canReceiveKeys()) {
if (!window.canReceiveKeys()) {
// If the window that received the input event cannot receive keys, don't move the
// display it's on to the top since that window won't be able to get focus anyway.
return;