diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index 23065b5f60..5afc5eda6d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.taskbar; +import static com.android.launcher3.Flags.enableAltTabKqsOnConnectedDisplays; + import android.content.ComponentName; import android.content.pm.ActivityInfo; import android.view.MotionEvent; @@ -272,11 +274,26 @@ public final class KeyboardQuickSwitchController implements } private void processLoadedTasksOnDesktop(List tasks, Set taskIdsToExclude) { - // Find the single desktop task that contains a grouping of desktop tasks - DesktopTask desktopTask = findDesktopTask(tasks); + // Find all desktop tasks. + List desktopTasks = tasks.stream() + .filter(t -> t instanceof DesktopTask) + .map(t -> (DesktopTask) t) + .toList(); - if (desktopTask != null) { - mTasks = desktopTask.getTasks().stream() + // Apps on the connected displays seem to be in different Desktop tasks even with the + // multiple desktops flag disabled. So, until multiple desktops is implemented the following + // should help with team-fooding Alt+tab on connected displays. Post multiple desktop, + // further changes maybe required to support launching selected desktops. + if (enableAltTabKqsOnConnectedDisplays()) { + mTasks = desktopTasks.stream() + .flatMap(t -> t.getTasks().stream()) + .map(SingleTask::new) + .filter(task -> !shouldExcludeTask(task, taskIdsToExclude)) + .collect(Collectors.toList()); + + mNumHiddenTasks = Math.max(0, tasks.size() - desktopTasks.size()); + } else if (!desktopTasks.isEmpty()) { + mTasks = desktopTasks.get(0).getTasks().stream() .map(SingleTask::new) .filter(task -> !shouldExcludeTask(task, taskIdsToExclude)) .collect(Collectors.toList()); @@ -289,14 +306,6 @@ public final class KeyboardQuickSwitchController implements } } - @Nullable - private DesktopTask findDesktopTask(List tasks) { - return (DesktopTask) tasks.stream() - .filter(t -> t instanceof DesktopTask) - .findFirst() - .orElse(null); - } - void closeQuickSwitchView() { closeQuickSwitchView(true); }