Commit 3eaeb740 authored by Regan Hsu's avatar Regan Hsu Committed by Commit Bot

[CrOS Wallpaper] Activate last available window on Wallpaper app close.

Currently, when the Wallpaper app closes, the most recently used window
is not re-activated.  This CL ensures that the most recently used
window is activated, allowing keyboard commands to work.

Change-Id: I1cc6e424f52f73e484bfb61044d321b6639516c8
Bug: 868543
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1629701
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665765}
parent e4a27d3e
......@@ -12,6 +12,26 @@
namespace ash {
namespace {
// Reactivate the most recently unminimized window on the active desk so as not
// to activate any desk that has been explicitly navigated away from, nor
// activate any window that has been explicitly minimized.
void ActivateMruUnminimizedWindowOnActiveDesk() {
MruWindowTracker::WindowList mru_windows(
Shell::Get()->mru_window_tracker()->BuildMruWindowList(
DesksMruType::kActiveDesk));
for (auto* window : mru_windows) {
if (wm::GetWindowState(window)->GetStateType() !=
WindowStateType::kMinimized) {
wm::GetWindowState(window)->Activate();
return;
}
}
}
} // namespace
WallpaperWindowStateManager::WallpaperWindowStateManager() = default;
WallpaperWindowStateManager::~WallpaperWindowStateManager() = default;
......@@ -63,6 +83,8 @@ void WallpaperWindowStateManager::RestoreMinimizedWindows(
wm::GetWindowState(*iter)->Unminimize();
RemoveObserverIfUnreferenced(*iter);
}
ActivateMruUnminimizedWindowOnActiveDesk();
}
void WallpaperWindowStateManager::RemoveObserverIfUnreferenced(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment