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/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 // Returns a list of windows ordered by their stacking order. | 41 // Returns a list of windows ordered by their stacking order. |
42 // If |mru_windows| is passed, these windows are moved to the front of the list. | 42 // If |mru_windows| is passed, these windows are moved to the front of the list. |
43 // It uses the given |should_include_window_predicate| to determine whether to | 43 // It uses the given |should_include_window_predicate| to determine whether to |
44 // include a window in the returned list or not. | 44 // include a window in the returned list or not. |
45 MruWindowTracker::WindowList BuildWindowListInternal( | 45 MruWindowTracker::WindowList BuildWindowListInternal( |
46 const std::list<WmWindow*>* mru_windows, | 46 const std::list<WmWindow*>* mru_windows, |
47 const CanActivateWindowPredicate& should_include_window_predicate) { | 47 const CanActivateWindowPredicate& should_include_window_predicate) { |
48 MruWindowTracker::WindowList windows; | 48 MruWindowTracker::WindowList windows; |
49 WmWindow* active_root = Shell::GetWmRootWindowForNewWindows(); | 49 aura::Window* active_root = Shell::GetRootWindowForNewWindows(); |
50 for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) { | 50 for (WmWindow* window : ShellPort::Get()->GetAllRootWindows()) { |
51 if (window == active_root) | 51 if (window->aura_window() == active_root) |
52 continue; | 52 continue; |
53 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) | 53 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) |
54 AddTrackedWindows(window, wm::kSwitchableWindowContainerIds[i], &windows); | 54 AddTrackedWindows(window, wm::kSwitchableWindowContainerIds[i], &windows); |
55 } | 55 } |
56 | 56 |
57 // Add windows in the active root windows last so that the topmost window | 57 // Add windows in the active root windows last so that the topmost window |
58 // in the active root window becomes the front of the list. | 58 // in the active root window becomes the front of the list. |
59 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) | 59 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { |
60 AddTrackedWindows(active_root, wm::kSwitchableWindowContainerIds[i], | 60 AddTrackedWindows(WmWindow::Get(active_root), |
61 &windows); | 61 wm::kSwitchableWindowContainerIds[i], &windows); |
| 62 } |
62 | 63 |
63 // Removes unfocusable windows. | 64 // Removes unfocusable windows. |
64 std::vector<WmWindow*>::iterator itr = windows.begin(); | 65 std::vector<WmWindow*>::iterator itr = windows.begin(); |
65 while (itr != windows.end()) { | 66 while (itr != windows.end()) { |
66 if (!should_include_window_predicate.Run(*itr)) | 67 if (!should_include_window_predicate.Run(*itr)) |
67 itr = windows.erase(itr); | 68 itr = windows.erase(itr); |
68 else | 69 else |
69 ++itr; | 70 ++itr; |
70 } | 71 } |
71 | 72 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 158 |
158 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) { | 159 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) { |
159 // It's possible for OnWindowActivated() to be called after | 160 // It's possible for OnWindowActivated() to be called after |
160 // OnWindowDestroying(). This means we need to override OnWindowDestroyed() | 161 // OnWindowDestroying(). This means we need to override OnWindowDestroyed() |
161 // else we may end up with a deleted window in |mru_windows_|. | 162 // else we may end up with a deleted window in |mru_windows_|. |
162 mru_windows_.remove(WmWindow::Get(window)); | 163 mru_windows_.remove(WmWindow::Get(window)); |
163 window->RemoveObserver(this); | 164 window->RemoveObserver(this); |
164 } | 165 } |
165 | 166 |
166 } // namespace ash | 167 } // namespace ash |
OLD | NEW |