| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/mru_window_tracker.h" | 5 #include "ash/wm/mru_window_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/session_state_delegate.h" | 9 #include "ash/session_state_delegate.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
| 12 #include "ash/wm/window_cycle_list.h" | 12 #include "ash/wm/window_cycle_list.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "ash/wm/workspace_controller.h" | 14 #include "ash/wm/workspace_controller.h" |
| 15 #include "ui/aura/client/activation_client.h" | 15 #include "ui/aura/client/activation_client.h" |
| 16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
| 17 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
| 18 #include "ui/events/event_handler.h" | 18 #include "ui/events/event_handler.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Adds the windows that can be cycled through for the specified window id to | 24 // Adds the windows that can be cycled through for the specified window id to |
| 25 // |windows|. | 25 // |windows|. |
| 26 void AddTrackedWindows(aura::RootWindow* root, | 26 void AddTrackedWindows(aura::Window* root, |
| 27 int container_id, | 27 int container_id, |
| 28 MruWindowTracker::WindowList* windows) { | 28 MruWindowTracker::WindowList* windows) { |
| 29 aura::Window* container = Shell::GetContainer(root, container_id); | 29 aura::Window* container = Shell::GetContainer(root, container_id); |
| 30 const MruWindowTracker::WindowList& children(container->children()); | 30 const MruWindowTracker::WindowList& children(container->children()); |
| 31 windows->insert(windows->end(), children.begin(), children.end()); | 31 windows->insert(windows->end(), children.begin(), children.end()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Returns true if |window| is a container whose windows can be cycled to. | 34 // Returns true if |window| is a container whose windows can be cycled to. |
| 35 bool IsSwitchableContainer(aura::Window* window) { | 35 bool IsSwitchableContainer(aura::Window* window) { |
| 36 if (!window) | 36 if (!window) |
| 37 return false; | 37 return false; |
| 38 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { | 38 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 52 // Returns a list of windows ordered by their stacking order. | 52 // Returns a list of windows ordered by their stacking order. |
| 53 // If |mru_windows| is passed, these windows are moved to the front of the list. | 53 // If |mru_windows| is passed, these windows are moved to the front of the list. |
| 54 // If |top_most_at_end|, the list is returned in descending (bottom-most / least | 54 // If |top_most_at_end|, the list is returned in descending (bottom-most / least |
| 55 // recently used) order. | 55 // recently used) order. |
| 56 MruWindowTracker::WindowList BuildWindowListInternal( | 56 MruWindowTracker::WindowList BuildWindowListInternal( |
| 57 const std::list<aura::Window*>* mru_windows, | 57 const std::list<aura::Window*>* mru_windows, |
| 58 bool top_most_at_end) { | 58 bool top_most_at_end) { |
| 59 MruWindowTracker::WindowList windows; | 59 MruWindowTracker::WindowList windows; |
| 60 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 60 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 61 | 61 |
| 62 aura::RootWindow* active_root = Shell::GetTargetRootWindow(); | 62 aura::Window* active_root = Shell::GetTargetRootWindow(); |
| 63 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); | 63 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
| 64 iter != root_windows.end(); ++iter) { | 64 iter != root_windows.end(); ++iter) { |
| 65 if (*iter == active_root) | 65 if (*iter == active_root) |
| 66 continue; | 66 continue; |
| 67 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) | 67 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) |
| 68 AddTrackedWindows(*iter, kSwitchableWindowContainerIds[i], &windows); | 68 AddTrackedWindows(*iter, kSwitchableWindowContainerIds[i], &windows); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Add windows in the active root windows last so that the topmost window | 71 // Add windows in the active root windows last so that the topmost window |
| 72 // in the active root window becomes the front of the list. | 72 // in the active root window becomes the front of the list. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if (!ignore_window_activations_) | 189 if (!ignore_window_activations_) |
| 190 SetActiveWindow(gained_active); | 190 SetActiveWindow(gained_active); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void MruWindowTracker::OnWindowDestroying(aura::Window* window) { | 193 void MruWindowTracker::OnWindowDestroying(aura::Window* window) { |
| 194 mru_windows_.remove(window); | 194 mru_windows_.remove(window); |
| 195 window->RemoveObserver(this); | 195 window->RemoveObserver(this); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace ash | 198 } // namespace ash |
| OLD | NEW |