Merge "Only switch task focus to window's task that was tapped outside current focus" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
da8ecc5154
@@ -2361,33 +2361,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
|
|||||||
layoutAndAssignWindowLayersIfNeeded();
|
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.
|
* Returns true if the input point is within an app window.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -127,7 +127,6 @@ class TaskPositioningController {
|
|||||||
|
|
||||||
void handleTapOutsideTask(DisplayContent displayContent, int x, int y) {
|
void handleTapOutsideTask(DisplayContent displayContent, int x, int y) {
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
int taskId = -1;
|
|
||||||
synchronized (mService.mGlobalLock) {
|
synchronized (mService.mGlobalLock) {
|
||||||
final Task task = displayContent.findTaskForResizePoint(x, y);
|
final Task task = displayContent.findTaskForResizePoint(x, y);
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
@@ -135,15 +134,10 @@ class TaskPositioningController {
|
|||||||
task.preserveOrientationOnResize(), x, y)) {
|
task.preserveOrientationOnResize(), x, y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
taskId = task.mTaskId;
|
try {
|
||||||
} else {
|
mActivityManager.setFocusedTask(task.mTaskId);
|
||||||
taskId = displayContent.taskForTapOutside(x, y);
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (taskId >= 0) {
|
|
||||||
try {
|
|
||||||
mActivityManager.setFocusedTask(taskId);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1458,31 +1458,6 @@ public class TaskStack extends WindowContainer<Task> implements
|
|||||||
return false;
|
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,
|
void findTaskForResizePoint(int x, int y, int delta,
|
||||||
DisplayContent.TaskForResizePointSearchResult results) {
|
DisplayContent.TaskForResizePointSearchResult results) {
|
||||||
if (!getWindowConfiguration().canResizeTask()) {
|
if (!getWindowConfiguration().canResizeTask()) {
|
||||||
|
|||||||
@@ -7587,12 +7587,36 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
return;
|
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) {
|
if (displayContent == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!touchedWindow.canReceiveKeys()) {
|
if (!window.canReceiveKeys()) {
|
||||||
// If the window that received the input event cannot receive keys, don't move the
|
// 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.
|
// display it's on to the top since that window won't be able to get focus anyway.
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user