From 135e6f999f60f7ee115c9a9b6771d19844ec79c1 Mon Sep 17 00:00:00 2001 From: Will Osborn Date: Wed, 16 Apr 2025 13:37:14 +0000 Subject: [PATCH] Recents keyboard switch on focused display Use the focused display for overview show and toggle commands from keyboard events Bug: 404854138 Test: local + presubmits Flag: com.android.launcher3.enable_overview_on_connected_displays Change-Id: I0e88a4312c3157e318fe2629c9fc27fe9e582351 --- .../quickstep/TouchInteractionService.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index db4ff9a0e4..d074da272d 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -218,15 +218,15 @@ public class TouchInteractionService extends Service { public void onOverviewToggle() { TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onOverviewToggle"); executeForTouchInteractionService(tis -> { - // TODO: update for non-default displays. + int displayId = tis.focusedDisplayIdForOverviewOnConnectedDisplays(); RecentsAnimationDeviceState deviceState = tis.mDeviceStateRepository.get( - DEFAULT_DISPLAY); + displayId); // If currently screen pinning, do not enter overview if (deviceState != null && deviceState.isScreenPinningActive()) { return; } TaskUtils.closeSystemWindowsAsync(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); - tis.mOverviewCommandHelper.addCommand(CommandType.TOGGLE, DEFAULT_DISPLAY); + tis.mOverviewCommandHelper.addCommand(CommandType.TOGGLE, displayId); }); } @@ -236,12 +236,11 @@ public class TouchInteractionService extends Service { executeForTouchInteractionService(tis -> { if (triggeredFromAltTab) { TaskUtils.closeSystemWindowsAsync(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); - int displayId = enableAltTabKqsOnConnectedDisplays.isTrue() - ? SystemUiProxy.INSTANCE.get(tis).getFocusState().getFocusedDisplayId() - : DEFAULT_DISPLAY; - tis.mOverviewCommandHelper.addCommand(CommandType.SHOW_ALT_TAB, displayId); + tis.mOverviewCommandHelper.addCommand(CommandType.SHOW_ALT_TAB, + tis.focusedDisplayIdForAltTabKqsOnConnectedDisplays()); } else { - tis.mOverviewCommandHelper.addCommand(CommandType.SHOW_WITH_FOCUS); + tis.mOverviewCommandHelper.addCommand(CommandType.SHOW_WITH_FOCUS, + tis.focusedDisplayIdForOverviewOnConnectedDisplays()); } }); } @@ -252,9 +251,7 @@ public class TouchInteractionService extends Service { executeForTouchInteractionService(tis -> { if (triggeredFromAltTab && !triggeredFromHomeKey) { // onOverviewShownFromAltTab hides the overview and ends at the target app - int displayId = enableAltTabKqsOnConnectedDisplays.isTrue() - ? SystemUiProxy.INSTANCE.get(tis).getFocusState().getFocusedDisplayId() - : DEFAULT_DISPLAY; + int displayId = tis.focusedDisplayIdForAltTabKqsOnConnectedDisplays(); tis.mOverviewCommandHelper.addCommand(CommandType.HIDE_ALT_TAB, displayId); } }); @@ -1360,6 +1357,19 @@ public class TouchInteractionService extends Service { mInputConsumer, MSDLPlayerWrapper.INSTANCE.get(this)); } + private int focusedDisplayIdForOverviewOnConnectedDisplays() { + return enableOverviewOnConnectedDisplays() + ? SystemUiProxy.INSTANCE.get(this).getFocusState().getFocusedDisplayId() + : DEFAULT_DISPLAY; + } + + private int focusedDisplayIdForAltTabKqsOnConnectedDisplays() { + return enableAltTabKqsOnConnectedDisplays.isTrue() + ? SystemUiProxy.INSTANCE.get(this).getFocusState().getFocusedDisplayId() + : DEFAULT_DISPLAY; + } + + /** * Helper class that keeps track of external displays and prepares input monitors for each. */