Properly size tasks based on stack size.

There were a few places we weren’t doing this correctly

* When a new task is created the bounds should be the stack bounds
if the task is resizeable and not in freeform mode.
* When resizing a stack each task in the stack should be resized
base on if it is resizable vs. using the top running activity in
the stack to determine if all the tasks should be resized.

Change-Id: If3448c5629313e7e7fb91ffe8506014f16ad72db
This commit is contained in:
Wale Ogunwale
2015-09-21 18:37:15 -07:00
parent 31cb4bb41f
commit a6e902ec61
5 changed files with 18 additions and 28 deletions

View File

@@ -4564,6 +4564,8 @@ final class ActivityStack {
addTask(task, toTop, false);
if (mTaskPositioner != null) {
mTaskPositioner.updateDefaultBounds(task, mTaskHistory, info.initialLayout);
} else if (mBounds != null && task.mResizeable) {
task.updateOverrideConfiguration(mBounds);
}
return task;
}

View File

@@ -2971,31 +2971,29 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
ActivityRecord r = stack.topRunningActivityLocked(null);
final boolean resizeTasks = r != null && r.task.mResizeable;
mTmpBounds.clear();
mTmpConfigs.clear();
if (resizeTasks) {
ArrayList<TaskRecord> tasks = stack.getAllTasks();
for (int i = tasks.size() - 1; i >= 0; i--) {
TaskRecord task = tasks.get(i);
ArrayList<TaskRecord> tasks = stack.getAllTasks();
for (int i = tasks.size() - 1; i >= 0; i--) {
TaskRecord task = tasks.get(i);
if (task.mResizeable) {
if (stack.mStackId == FREEFORM_WORKSPACE_STACK_ID) {
// For freeform stack we don't adjust the size of the tasks to match that of
// the stack, but we do try to make sure the tasks are still contained with the
// bounds of the stack.
// For freeform stack we don't adjust the size of the tasks to match that
// of the stack, but we do try to make sure the tasks are still contained
// with the bounds of the stack.
tempRect2.set(task.mBounds);
fitWithinBounds(tempRect2, bounds);
task.updateOverrideConfiguration(tempRect2);
} else {
task.updateOverrideConfiguration(bounds);
}
mTmpConfigs.put(task.taskId, task.mOverrideConfig);
mTmpBounds.put(task.taskId, task.mBounds);
}
mTmpConfigs.put(task.taskId, task.mOverrideConfig);
mTmpBounds.put(task.taskId, task.mBounds);
}
stack.mFullscreen = mWindowManager.resizeStack(stackId, bounds, resizeTasks, mTmpConfigs,
mTmpBounds);
stack.mFullscreen = mWindowManager.resizeStack(stackId, bounds, mTmpConfigs, mTmpBounds);
if (stack.mStackId == DOCKED_STACK_ID) {
// Dock stack funness...Yay!
if (stack.mFullscreen) {
@@ -3008,7 +3006,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
}
final ArrayList<TaskRecord> tasks = stack.getAllTasks();
final int count = tasks.size();
for (int i = 0; i < count; i++) {
moveTaskToStackLocked(tasks.get(i).taskId,

View File

@@ -1235,7 +1235,7 @@ final class TaskRecord {
if (stack == null
|| stack.mStackId == HOME_STACK_ID
|| stack.mStackId == FULLSCREEN_WORKSPACE_STACK_ID) {
return null;
return (mResizeable && stack != null) ? stack.mBounds : null;
} else if (stack.mStackId == DOCKED_STACK_ID) {
return stack.mBounds;
}

View File

@@ -118,30 +118,22 @@ public class TaskStack implements DimLayer.DimLayerUser {
/**
* Set the bounds of the stack and its containing tasks.
* @param stackBounds New stack bounds. Passing in null sets the bounds to fullscreen.
* @param resizeTasks If true, the tasks within the stack will also be resized.
* @param configs Configuration for individual tasks, keyed by task id.
* @param taskBounds Bounds for individual tasks, keyed by task id.
* @return True if the stack bounds was changed.
* */
boolean setBounds(Rect stackBounds, boolean resizeTasks, SparseArray<Configuration> configs,
SparseArray<Rect> taskBounds) {
boolean setBounds(
Rect stackBounds, SparseArray<Configuration> configs, SparseArray<Rect> taskBounds) {
if (!setBounds(stackBounds)) {
return false;
}
if (!resizeTasks) {
return true;
}
// Update bounds of containing tasks.
for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
final Task task = mTasks.get(taskNdx);
Configuration config = configs.get(task.mTaskId);
if (config != null) {
Rect bounds = taskBounds.get(task.mTaskId);
if (bounds == null) {
bounds = stackBounds;
}
task.setBounds(bounds, config);
} else {
Slog.wtf(TAG, "No config for task: " + task + ", is there a mismatch with AM?");

View File

@@ -4632,12 +4632,11 @@ public class WindowManagerService extends IWindowManager.Stub
* Re-sizes a stack and its containing tasks.
* @param stackId Id of stack to resize.
* @param bounds New stack bounds. Passing in null sets the bounds to fullscreen.
* @param resizeTasks If true, the tasks within the stack will also be resized.
* @param configs Configurations for tasks in the resized stack, keyed by task id.
* @param taskBounds Bounds for tasks in the resized stack, keyed by task id.
* @return True if the stack is now fullscreen.
* */
public boolean resizeStack(int stackId, Rect bounds, boolean resizeTasks,
public boolean resizeStack(int stackId, Rect bounds,
SparseArray<Configuration> configs, SparseArray<Rect> taskBounds) {
synchronized (mWindowMap) {
final TaskStack stack = mStackIdToStack.get(stackId);
@@ -4645,7 +4644,7 @@ public class WindowManagerService extends IWindowManager.Stub
throw new IllegalArgumentException("resizeStack: stackId " + stackId
+ " not found.");
}
if (stack.setBounds(bounds, resizeTasks, configs, taskBounds)) {
if (stack.setBounds(bounds, configs, taskBounds)) {
stack.resizeWindows();
stack.getDisplayContent().layoutNeeded = true;
mWindowPlacerLocked.performSurfacePlacement();