OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/window_cycle_controller.h" | 5 #include "ash/wm/window_cycle_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 void WindowCycleController::AltKeyReleased() { | 124 void WindowCycleController::AltKeyReleased() { |
125 StopCycling(); | 125 StopCycling(); |
126 } | 126 } |
127 | 127 |
128 // static | 128 // static |
129 std::vector<aura::Window*> WindowCycleController::BuildWindowList() { | 129 std::vector<aura::Window*> WindowCycleController::BuildWindowList() { |
130 WindowCycleList::WindowList windows; | 130 WindowCycleList::WindowList windows; |
131 WindowCycleList::WindowList top_windows; | |
131 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 132 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
132 | 133 |
133 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); | 134 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
134 iter != root_windows.end(); ++iter) { | 135 iter != root_windows.end(); ++iter) { |
135 if (*iter == Shell::GetActiveRootWindow()) | 136 if (*iter == Shell::GetActiveRootWindow()) |
136 continue; | 137 continue; |
138 aura::Window* always_on_top_container = Shell::GetContainer( | |
139 *iter, internal::kShellWindowId_AlwaysOnTopContainer); | |
140 WindowCycleList::WindowList children = always_on_top_container->children(); | |
141 top_windows.insert(top_windows.end(), children.begin(), children.end()); | |
142 | |
137 aura::Window* default_container = Shell::GetContainer( | 143 aura::Window* default_container = Shell::GetContainer( |
138 *iter, internal::kShellWindowId_DefaultContainer); | 144 *iter, internal::kShellWindowId_DefaultContainer); |
139 WindowCycleList::WindowList children = default_container->children(); | 145 children = default_container->children(); |
140 windows.insert(windows.end(), children.begin(), children.end()); | 146 windows.insert(windows.end(), children.begin(), children.end()); |
141 } | 147 } |
148 | |
142 // Add windows in the active root windows last so that the topmost window | 149 // Add windows in the active root windows last so that the topmost window |
143 // in the active root window becomes the front of the list. | 150 // in the active root window becomes the front of the list. |
151 aura::Window* always_on_top_container = Shell::GetContainer( | |
152 Shell::GetActiveRootWindow(), | |
153 internal::kShellWindowId_AlwaysOnTopContainer); | |
154 | |
155 WindowCycleList::WindowList children = always_on_top_container->children(); | |
156 top_windows.insert(top_windows.end(), children.begin(), children.end()); | |
157 | |
144 aura::Window* default_container = Shell::GetContainer( | 158 aura::Window* default_container = Shell::GetContainer( |
145 Shell::GetActiveRootWindow(), | 159 Shell::GetActiveRootWindow(), |
146 internal::kShellWindowId_DefaultContainer); | 160 internal::kShellWindowId_DefaultContainer); |
147 | 161 |
148 WindowCycleList::WindowList children = default_container->children(); | 162 children = default_container->children(); |
149 windows.insert(windows.end(), children.begin(), children.end()); | 163 windows.insert(windows.end(), children.begin(), children.end()); |
150 | 164 |
151 // Removes unfocusable windows. | 165 // Removes unfocusable windows. |
152 WindowCycleList::WindowList::iterator last = | 166 WindowCycleList::WindowList::iterator last = |
153 std::remove_if( | 167 std::remove_if( |
154 windows.begin(), | 168 windows.begin(), |
155 windows.end(), | 169 windows.end(), |
156 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); | 170 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); |
157 windows.erase(last, windows.end()); | 171 windows.erase(last, windows.end()); |
172 | |
173 last = std::remove_if( | |
174 top_windows.begin(), | |
175 top_windows.end(), | |
176 std::not1(std::ptr_fun(ash::wm::CanActivateWindow))); | |
177 top_windows.erase(last, top_windows.end()); | |
178 | |
158 // Window cycling expects the topmost window at the front of the list. | 179 // Window cycling expects the topmost window at the front of the list. |
159 std::reverse(windows.begin(), windows.end()); | 180 std::reverse(windows.begin(), windows.end()); |
181 | |
182 // Always on top windows should be in the list after the active window. | |
183 aura::Window* active_window = wm::GetActiveWindow(); | |
184 WindowCycleList::WindowList::iterator active_location = | |
185 std::find(windows.begin(), windows.end(), active_window); | |
186 if (active_location == windows.end()) { | |
187 // If there's no active window, insert at the beginning of the list. | |
188 windows.insert(windows.begin(), top_windows.begin(), top_windows.end()); | |
189 } else { | |
190 active_location++; | |
191 windows.insert(active_location, top_windows.begin(), top_windows.end()); | |
Daniel Erat
2012/07/11 14:53:41
Is this putting always-on-top windows from other d
Daniel Erat
2012/07/13 14:07:12
Sorry, s/desktop/root window/g in this comment. A
oshima
2012/07/13 14:53:30
I agree with dan. I think that's what a user would
| |
192 } | |
193 | |
160 return windows; | 194 return windows; |
161 } | 195 } |
162 | 196 |
163 ////////////////////////////////////////////////////////////////////////////// | 197 ////////////////////////////////////////////////////////////////////////////// |
164 // WindowCycleController, private: | 198 // WindowCycleController, private: |
165 | 199 |
166 void WindowCycleController::StartCycling() { | 200 void WindowCycleController::StartCycling() { |
167 windows_.reset(new WindowCycleList(BuildWindowList())); | 201 windows_.reset(new WindowCycleList(BuildWindowList())); |
168 } | 202 } |
169 | 203 |
(...skipping 11 matching lines...) Expand all Loading... | |
181 event_filter_.reset(); | 215 event_filter_.reset(); |
182 } | 216 } |
183 } | 217 } |
184 | 218 |
185 void WindowCycleController::InstallEventFilter() { | 219 void WindowCycleController::InstallEventFilter() { |
186 event_filter_.reset(new WindowCycleEventFilter()); | 220 event_filter_.reset(new WindowCycleEventFilter()); |
187 Shell::GetInstance()->AddEnvEventFilter(event_filter_.get()); | 221 Shell::GetInstance()->AddEnvEventFilter(event_filter_.get()); |
188 } | 222 } |
189 | 223 |
190 } // namespace ash | 224 } // namespace ash |
OLD | NEW |