From 9e76d3292b34c8683b549cc1f56bfff288defb92 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Fri, 22 Apr 2016 12:37:57 -0700 Subject: [PATCH] Touch region fixes for dialogs and overlapping tasks. There were two errors. First the function assumes that there are only overlapping tasks in the case of freeform, and so otherwise it is not necessary to union the focused task back at the end (and we can just subtract all the non focused tasks). This won't work though, as there can be for example dialogs over the launcher from another task. We need to always add back the focused task. Secondly, we were requiring a task to have a top visible "main app window" e.g. TYPE_APPLICATION or TYPE_APPLICATION_STARTING. For tasks whose only presence on screen is a dialog this will skip them and we will ignore them one way or another. Bug: 26962445 Change-Id: Idd5c54082409e7c34d9fc7480908c88fb12b378b --- .../com/android/server/wm/DisplayContent.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 1f1648116b9d3..037eb5add22d4 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -364,8 +364,8 @@ class DisplayContent { final ArrayList tasks = stack.getTasks(); for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) { final Task task = tasks.get(taskNdx); - final WindowState win = task.getTopVisibleAppMainWindow(); - if (win == null) { + AppWindowToken token = task.getTopVisibleAppToken(); + if (token == null || !token.isVisible()) { continue; } @@ -375,20 +375,18 @@ class DisplayContent { * We also remove the outside touch area for resizing for all freeform * tasks (including the focused). * - * (For freeform focused task, the below logic will first remove the enlarged - * area, then add back the inner area.) + * We save the focused task region once we find it, and add it back at the end. */ + + if (task == focusedTask) { + addBackFocusedTask = true; + mTmpRect2.set(mTmpRect); + } + final boolean isFreeformed = task.inFreeformWorkspace(); if (task != focusedTask || isFreeformed) { task.getDimBounds(mTmpRect); if (isFreeformed) { - // If we're removing a freeform, focused app from the exclusion region, - // we need to add back its touchable frame later. Remember the touchable - // frame now. - if (task == focusedTask) { - addBackFocusedTask = true; - mTmpRect2.set(mTmpRect); - } // If the task is freeformed, enlarge the area to account for outside // touch area for resize. mTmpRect.inset(-delta, -delta);