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_state.h" |
13 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
14 #include "ash/wm/workspace_controller.h" | 15 #include "ash/wm/workspace_controller.h" |
15 #include "ui/aura/client/activation_client.h" | 16 #include "ui/aura/client/activation_client.h" |
16 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
18 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.h" |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Adds the windows that can be cycled through for the specified window id to | 25 // Adds the windows that can be cycled through for the specified window id to |
25 // |windows|. | 26 // |windows|. |
26 void AddTrackedWindows(aura::Window* root, | 27 void AddTrackedWindows(aura::Window* root, |
27 int container_id, | 28 int container_id, |
28 MruWindowTracker::WindowList* windows) { | 29 MruWindowTracker::WindowList* windows) { |
29 aura::Window* container = Shell::GetContainer(root, container_id); | 30 aura::Window* container = Shell::GetContainer(root, container_id); |
30 const MruWindowTracker::WindowList& children(container->children()); | 31 const MruWindowTracker::WindowList& children(container->children()); |
31 windows->insert(windows->end(), children.begin(), children.end()); | 32 windows->insert(windows->end(), children.begin(), children.end()); |
32 } | 33 } |
33 | 34 |
| 35 // Adds windows being dragged in the docked container to |windows| list. |
| 36 void AddDraggedWindows(aura::Window* root, |
| 37 MruWindowTracker::WindowList* windows) { |
| 38 aura::Window* container = Shell::GetContainer( |
| 39 root, internal::kShellWindowId_DockedContainer); |
| 40 const MruWindowTracker::WindowList& children = container->children(); |
| 41 for (MruWindowTracker::WindowList::const_iterator iter = children.begin(); |
| 42 iter != children.end(); ++iter) { |
| 43 if (wm::GetWindowState(*iter)->is_dragged()) |
| 44 windows->insert(windows->end(), *iter); |
| 45 } |
| 46 } |
| 47 |
34 // Returns true if |window| is a container whose windows can be cycled to. | 48 // Returns true if |window| is a container whose windows can be cycled to. |
35 bool IsSwitchableContainer(aura::Window* window) { | 49 bool IsSwitchableContainer(aura::Window* window) { |
36 if (!window) | 50 if (!window) |
37 return false; | 51 return false; |
38 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { | 52 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { |
39 if (window->id() == kSwitchableWindowContainerIds[i]) | 53 if (window->id() == kSwitchableWindowContainerIds[i]) |
40 return true; | 54 return true; |
41 } | 55 } |
42 return false; | 56 return false; |
43 } | 57 } |
(...skipping 22 matching lines...) Expand all Loading... |
66 continue; | 80 continue; |
67 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) | 81 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) |
68 AddTrackedWindows(*iter, kSwitchableWindowContainerIds[i], &windows); | 82 AddTrackedWindows(*iter, kSwitchableWindowContainerIds[i], &windows); |
69 } | 83 } |
70 | 84 |
71 // Add windows in the active root windows last so that the topmost window | 85 // 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. | 86 // in the active root window becomes the front of the list. |
73 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) | 87 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) |
74 AddTrackedWindows(active_root, kSwitchableWindowContainerIds[i], &windows); | 88 AddTrackedWindows(active_root, kSwitchableWindowContainerIds[i], &windows); |
75 | 89 |
| 90 // Dragged windows are temporarily parented in docked container. Include them |
| 91 // in the in tracked list. |
| 92 AddDraggedWindows(active_root, &windows); |
| 93 |
76 // Removes unfocusable windows. | 94 // Removes unfocusable windows. |
77 MruWindowTracker::WindowList::iterator last = | 95 MruWindowTracker::WindowList::iterator last = |
78 std::remove_if( | 96 std::remove_if( |
79 windows.begin(), | 97 windows.begin(), |
80 windows.end(), | 98 windows.end(), |
81 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); | 99 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); |
82 windows.erase(last, windows.end()); | 100 windows.erase(last, windows.end()); |
83 | 101 |
84 // Put the windows in the mru_windows list at the head, if it's available. | 102 // Put the windows in the mru_windows list at the head, if it's available. |
85 if (mru_windows) { | 103 if (mru_windows) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 if (!ignore_window_activations_) | 207 if (!ignore_window_activations_) |
190 SetActiveWindow(gained_active); | 208 SetActiveWindow(gained_active); |
191 } | 209 } |
192 | 210 |
193 void MruWindowTracker::OnWindowDestroying(aura::Window* window) { | 211 void MruWindowTracker::OnWindowDestroying(aura::Window* window) { |
194 mru_windows_.remove(window); | 212 mru_windows_.remove(window); |
195 window->RemoveObserver(this); | 213 window->RemoveObserver(this); |
196 } | 214 } |
197 | 215 |
198 } // namespace ash | 216 } // namespace ash |
OLD | NEW |