| Index: ash/wm/window_cycle_controller.cc
|
| diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
|
| index 3223018ce4e0408125f8d62f84d448841011ed49..9f12a134722fe5a6818ee0b5bbf17ce5bd48f1d7 100644
|
| --- a/ash/wm/window_cycle_controller.cc
|
| +++ b/ash/wm/window_cycle_controller.cc
|
| @@ -11,6 +11,7 @@
|
| #include "ash/wm/activation_controller.h"
|
| #include "ash/wm/window_cycle_list.h"
|
| #include "ash/wm/window_util.h"
|
| +#include "ash/wm/workspace_controller.h"
|
| #include "ui/aura/event_filter.h"
|
| #include "ui/aura/root_window.h"
|
| #include "ui/base/event.h"
|
| @@ -84,6 +85,34 @@ ui::GestureStatus WindowCycleEventFilter::PreHandleGestureEvent(
|
| return ui::GESTURE_STATUS_UNKNOWN; // Not handled.
|
| }
|
|
|
| +// Adds all the children of |window| to |windows|.
|
| +void AddAllChildren(aura::Window* window,
|
| + WindowCycleList::WindowList* windows) {
|
| + const WindowCycleList::WindowList& children(window->children());
|
| + windows->insert(windows->end(), children.begin(), children.end());
|
| +}
|
| +
|
| +// Adds all the children of all of |window|s children to |windows|.
|
| +void AddWorkspace2Children(aura::Window* window,
|
| + WindowCycleList::WindowList* windows) {
|
| + for (size_t i = 0; i < window->children().size(); ++i)
|
| + AddAllChildren(window->children()[i], windows);
|
| +}
|
| +
|
| +// Adds the windows that can be cycled through for the specified window id to
|
| +// |windows|.
|
| +void AddCycleWindows(aura::RootWindow* root,
|
| + int container_id,
|
| + WindowCycleList::WindowList* windows) {
|
| + aura::Window* container = Shell::GetContainer(root, container_id);
|
| + if (container_id == internal::kShellWindowId_DefaultContainer &&
|
| + internal::WorkspaceController::IsWorkspace2Enabled()) {
|
| + AddWorkspace2Children(container, windows);
|
| + } else {
|
| + AddAllChildren(container, windows);
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
| @@ -91,7 +120,7 @@ ui::GestureStatus WindowCycleEventFilter::PreHandleGestureEvent(
|
|
|
| WindowCycleController::WindowCycleController(
|
| internal::ActivationController* activation_controller)
|
| - : activation_controller_(activation_controller) {
|
| + : activation_controller_(activation_controller) {
|
| activation_controller_->AddObserver(this);
|
| }
|
|
|
| @@ -104,6 +133,16 @@ WindowCycleController::~WindowCycleController() {
|
| if (container)
|
| container->RemoveObserver(this);
|
| }
|
| + aura::Window* default_container =
|
| + Shell::GetContainer(*iter, internal::kShellWindowId_DefaultContainer);
|
| + if (default_container) {
|
| + for (size_t i = 0; i < default_container->children().size(); ++i) {
|
| + aura::Window* workspace_window = default_container->children()[i];
|
| + DCHECK_EQ(internal::kShellWindowId_WorkspaceContainer,
|
| + workspace_window->id());
|
| + workspace_window->RemoveObserver(this);
|
| + }
|
| + }
|
| }
|
|
|
| activation_controller_->RemoveObserver(this);
|
| @@ -152,26 +191,19 @@ std::vector<aura::Window*> WindowCycleController::BuildWindowList(
|
| WindowCycleList::WindowList windows;
|
| Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
|
|
|
| + aura::RootWindow* active_root = Shell::GetActiveRootWindow();
|
| for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
|
| iter != root_windows.end(); ++iter) {
|
| - if (*iter == Shell::GetActiveRootWindow())
|
| + if (*iter == active_root)
|
| continue;
|
| - for (size_t i = 0; i < arraysize(kContainerIds); ++i) {
|
| - aura::Window* container = Shell::GetContainer(*iter, kContainerIds[i]);
|
| - WindowCycleList::WindowList children = container->children();
|
| - windows.insert(windows.end(), children.begin(), children.end());
|
| - }
|
| + for (size_t i = 0; i < arraysize(kContainerIds); ++i)
|
| + AddCycleWindows(*iter, kContainerIds[i], &windows);
|
| }
|
|
|
| // Add windows in the active root windows last so that the topmost window
|
| // in the active root window becomes the front of the list.
|
| - for (size_t i = 0; i < arraysize(kContainerIds); ++i) {
|
| - aura::Window* container =
|
| - Shell::GetContainer(Shell::GetActiveRootWindow(), kContainerIds[i]);
|
| -
|
| - WindowCycleList::WindowList children = container->children();
|
| - windows.insert(windows.end(), children.begin(), children.end());
|
| - }
|
| + for (size_t i = 0; i < arraysize(kContainerIds); ++i)
|
| + AddCycleWindows(active_root, kContainerIds[i], &windows);
|
|
|
| // Removes unfocusable windows.
|
| WindowCycleList::WindowList::iterator last =
|
| @@ -209,6 +241,16 @@ void WindowCycleController::OnRootWindowAdded(aura::RootWindow* root_window) {
|
| Shell::GetContainer(root_window, kContainerIds[i]);
|
| container->AddObserver(this);
|
| }
|
| +
|
| + aura::Window* default_container =
|
| + Shell::GetContainer(root_window,
|
| + internal::kShellWindowId_DefaultContainer);
|
| + for (size_t i = 0; i < default_container->children().size(); ++i) {
|
| + aura::Window* workspace_window = default_container->children()[i];
|
| + DCHECK_EQ(internal::kShellWindowId_WorkspaceContainer,
|
| + workspace_window->id());
|
| + workspace_window->AddObserver(this);
|
| + }
|
| }
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
| @@ -247,7 +289,7 @@ bool WindowCycleController::IsTrackedContainer(aura::Window* window) {
|
| return true;
|
| }
|
| }
|
| - return false;
|
| + return window->id() == internal::kShellWindowId_WorkspaceContainer;
|
| }
|
|
|
| void WindowCycleController::InstallEventFilter() {
|
| @@ -263,8 +305,15 @@ void WindowCycleController::OnWindowActivated(aura::Window* active,
|
| }
|
| }
|
|
|
| +void WindowCycleController::OnWindowAdded(aura::Window* window) {
|
| + if (window->id() == internal::kShellWindowId_WorkspaceContainer)
|
| + window->AddObserver(this);
|
| +}
|
| +
|
| void WindowCycleController::OnWillRemoveWindow(aura::Window* window) {
|
| mru_windows_.remove(window);
|
| + if (window->id() == internal::kShellWindowId_WorkspaceContainer)
|
| + window->RemoveObserver(this);
|
| }
|
|
|
| void WindowCycleController::OnWindowDestroying(aura::Window* window) {
|
|
|