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 dragged windows that are children of the docked container during the | |
36 // drag to |windows|. | |
oshima
2014/01/08 01:33:03
// Adds windows being dragged in the docked contai
varkha
2014/01/09 05:14:20
Done.
| |
37 void AddDraggedWindows(aura::Window* root, | |
38 MruWindowTracker::WindowList* windows) { | |
39 aura::Window* container = Shell::GetContainer( | |
40 root, internal::kShellWindowId_DockedContainer); | |
41 const MruWindowTracker::WindowList& children(container->children()); | |
oshima
2014/01/08 01:33:03
nit: I prefer = instead of ()
varkha
2014/01/09 05:14:20
Done.
| |
42 for (MruWindowTracker::WindowList::const_iterator iter = children.begin(); | |
43 iter != children.end(); ++iter) { | |
44 if (wm::GetWindowState(*iter)->is_dragged()) | |
45 windows->insert(windows->end(), *iter); | |
46 } | |
47 } | |
48 | |
34 // Returns true if |window| is a container whose windows can be cycled to. | 49 // Returns true if |window| is a container whose windows can be cycled to. |
35 bool IsSwitchableContainer(aura::Window* window) { | 50 bool IsSwitchableContainer(aura::Window* window) { |
36 if (!window) | 51 if (!window) |
37 return false; | 52 return false; |
38 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { | 53 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { |
39 if (window->id() == kSwitchableWindowContainerIds[i]) | 54 if (window->id() == kSwitchableWindowContainerIds[i]) |
40 return true; | 55 return true; |
41 } | 56 } |
42 return false; | 57 return false; |
43 } | 58 } |
(...skipping 22 matching lines...) Expand all Loading... | |
66 continue; | 81 continue; |
67 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) | 82 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) |
68 AddTrackedWindows(*iter, kSwitchableWindowContainerIds[i], &windows); | 83 AddTrackedWindows(*iter, kSwitchableWindowContainerIds[i], &windows); |
69 } | 84 } |
70 | 85 |
71 // Add windows in the active root windows last so that the topmost window | 86 // 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. | 87 // in the active root window becomes the front of the list. |
73 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) | 88 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) |
74 AddTrackedWindows(active_root, kSwitchableWindowContainerIds[i], &windows); | 89 AddTrackedWindows(active_root, kSwitchableWindowContainerIds[i], &windows); |
75 | 90 |
91 // Dragged windows are temporarily parented in docked container. Include them | |
92 // in the in tracked list. | |
93 AddDraggedWindows(active_root, &windows); | |
94 | |
76 // Removes unfocusable windows. | 95 // Removes unfocusable windows. |
77 MruWindowTracker::WindowList::iterator last = | 96 MruWindowTracker::WindowList::iterator last = |
78 std::remove_if( | 97 std::remove_if( |
79 windows.begin(), | 98 windows.begin(), |
80 windows.end(), | 99 windows.end(), |
81 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); | 100 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); |
82 windows.erase(last, windows.end()); | 101 windows.erase(last, windows.end()); |
83 | 102 |
84 // Put the windows in the mru_windows list at the head, if it's available. | 103 // Put the windows in the mru_windows list at the head, if it's available. |
85 if (mru_windows) { | 104 if (mru_windows) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 if (!ignore_window_activations_) | 208 if (!ignore_window_activations_) |
190 SetActiveWindow(gained_active); | 209 SetActiveWindow(gained_active); |
191 } | 210 } |
192 | 211 |
193 void MruWindowTracker::OnWindowDestroying(aura::Window* window) { | 212 void MruWindowTracker::OnWindowDestroying(aura::Window* window) { |
194 mru_windows_.remove(window); | 213 mru_windows_.remove(window); |
195 window->RemoveObserver(this); | 214 window->RemoveObserver(this); |
196 } | 215 } |
197 | 216 |
198 } // namespace ash | 217 } // namespace ash |
OLD | NEW |