Index: ash/wm/window_cycle_controller.cc |
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc |
index f48ee76afa8f92f3d4aca34ba119b474c003141b..1aceb33f4cd99bfb85d1dd7a8503927ac0074a93 100644 |
--- a/ash/wm/window_cycle_controller.cc |
+++ b/ash/wm/window_cycle_controller.cc |
@@ -128,6 +128,7 @@ void WindowCycleController::AltKeyReleased() { |
// static |
std::vector<aura::Window*> WindowCycleController::BuildWindowList() { |
WindowCycleList::WindowList windows; |
+ WindowCycleList::WindowList top_windows; |
Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
@@ -138,14 +139,27 @@ std::vector<aura::Window*> WindowCycleController::BuildWindowList() { |
*iter, internal::kShellWindowId_DefaultContainer); |
WindowCycleList::WindowList children = default_container->children(); |
windows.insert(windows.end(), children.begin(), children.end()); |
+ |
+ aura::Window* always_on_top_container = Shell::GetContainer( |
sky
2012/07/17 17:43:37
Shouldn't always on top be added first?
Zachary Kuznia
2012/07/18 01:36:54
It's added last because the container is reversed
|
+ *iter, internal::kShellWindowId_AlwaysOnTopContainer); |
sky
2012/07/17 17:43:37
Rather than this define an array of the ids of the
Zachary Kuznia
2012/07/18 01:36:54
top_windows is handled differently, because they n
|
+ children = always_on_top_container->children(); |
+ windows.insert(windows.end(), children.begin(), children.end()); |
} |
+ |
// Add windows in the active root windows last so that the topmost window |
// in the active root window becomes the front of the list. |
+ aura::Window* always_on_top_container = Shell::GetContainer( |
+ Shell::GetActiveRootWindow(), |
+ internal::kShellWindowId_AlwaysOnTopContainer); |
+ |
+ WindowCycleList::WindowList children = always_on_top_container->children(); |
+ top_windows.insert(top_windows.end(), children.begin(), children.end()); |
+ |
aura::Window* default_container = Shell::GetContainer( |
Shell::GetActiveRootWindow(), |
internal::kShellWindowId_DefaultContainer); |
- WindowCycleList::WindowList children = default_container->children(); |
+ children = default_container->children(); |
windows.insert(windows.end(), children.begin(), children.end()); |
// Removes unfocusable windows. |
@@ -155,8 +169,28 @@ std::vector<aura::Window*> WindowCycleController::BuildWindowList() { |
windows.end(), |
std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); |
windows.erase(last, windows.end()); |
+ |
+ last = std::remove_if( |
+ top_windows.begin(), |
+ top_windows.end(), |
+ std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); |
+ top_windows.erase(last, top_windows.end()); |
+ |
// Window cycling expects the topmost window at the front of the list. |
std::reverse(windows.begin(), windows.end()); |
+ |
+ // Always on top windows should be in the list after the active window. |
+ aura::Window* active_window = wm::GetActiveWindow(); |
+ WindowCycleList::WindowList::iterator active_location = |
+ std::find(windows.begin(), windows.end(), active_window); |
+ if (active_location == windows.end()) { |
+ // If there's no active window, insert at the beginning of the list. |
+ windows.insert(windows.begin(), top_windows.begin(), top_windows.end()); |
+ } else { |
+ active_location++; |
+ windows.insert(active_location, top_windows.begin(), top_windows.end()); |
+ } |
+ |
return windows; |
} |