Index: ash/wm/mru_window_tracker.cc |
diff --git a/ash/wm/mru_window_tracker.cc b/ash/wm/mru_window_tracker.cc |
index 6b8b4cf6e2583b7de44f3c30b6d2bc5105547951..ef00dfc4e726cd6de376429d45af5cb5ec12605c 100644 |
--- a/ash/wm/mru_window_tracker.cc |
+++ b/ash/wm/mru_window_tracker.cc |
@@ -45,17 +45,20 @@ |
} |
} |
-// Returns whether |w1| should be considered more recently used than |w2|. This |
+// Returns whether |w1| should be considered less recently used than |w2|. This |
// is used for a stable sort to move minimized windows to the LRU end of the |
// list. |
bool CompareWindowState(aura::Window* w1, aura::Window* w2) { |
- return !(ash::wm::IsWindowMinimized(w1) && !ash::wm::IsWindowMinimized(w2)); |
+ return ash::wm::IsWindowMinimized(w1) && !ash::wm::IsWindowMinimized(w2); |
} |
// Returns a list of windows ordered by their stacking order. |
// If |mru_windows| is passed, these windows are moved to the front of the list. |
+// If |top_most_at_end|, the list is returned in descending (bottom-most / least |
+// recently used) order. |
MruWindowTracker::WindowList BuildWindowListInternal( |
- const std::list<aura::Window*>* mru_windows) { |
+ const std::list<aura::Window*>* mru_windows, |
+ bool top_most_at_end) { |
MruWindowTracker::WindowList windows; |
aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
@@ -108,9 +111,12 @@ |
} |
} |
+ // Move minimized windows to the beginning (LRU end) of the list. |
+ std::stable_sort(windows.begin(), windows.end(), CompareWindowState); |
+ |
// Window cycling expects the topmost window at the front of the list. |
- // Move minimized windows to the end (LRU end) of the list. |
- std::stable_sort(windows.begin(), windows.end(), CompareWindowState); |
+ if (!top_most_at_end) |
+ std::reverse(windows.begin(), windows.end()); |
return windows; |
} |
@@ -137,12 +143,13 @@ |
} |
// static |
-MruWindowTracker::WindowList MruWindowTracker::BuildWindowList() { |
- return BuildWindowListInternal(NULL); |
+MruWindowTracker::WindowList MruWindowTracker::BuildWindowList( |
+ bool top_most_at_end) { |
+ return BuildWindowListInternal(NULL, top_most_at_end); |
} |
MruWindowTracker::WindowList MruWindowTracker::BuildMruWindowList() { |
- return BuildWindowListInternal(&mru_windows_); |
+ return BuildWindowListInternal(&mru_windows_, false); |
} |
void MruWindowTracker::SetIgnoreActivations(bool ignore) { |