Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: ash/wm/window_cycle_controller.cc

Issue 12618014: Switch Next Window Key functionality (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: protect against alt+tab+switch_windows interaction Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_delegate.h" 9 #include "ash/shell_delegate.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 Step(direction); 142 Step(direction);
143 } 143 }
144 } else { 144 } else {
145 // This is a simple, single-step window cycle. 145 // This is a simple, single-step window cycle.
146 StartCycling(); 146 StartCycling();
147 Step(direction); 147 Step(direction);
148 StopCycling(); 148 StopCycling();
149 } 149 }
150 } 150 }
151 151
152 void WindowCycleController::HandleLinearCycleWindow() {
153 if (!CanCycle() || IsCycling())
154 return;
155
156 // Use the reversed list of windows to prevent a 2-cycle of the most recent
157 // windows occurring.
158 windows_.reset(new WindowCycleList(BuildWindowList(NULL, true)));
James Cook 2013/03/22 16:45:36 I would just make the WindowCycleList a local vari
159 Step(FORWARD);
160 windows_.reset();
161 }
162
152 void WindowCycleController::AltKeyReleased() { 163 void WindowCycleController::AltKeyReleased() {
153 StopCycling(); 164 StopCycling();
154 } 165 }
155 166
156 // static 167 // static
157 std::vector<aura::Window*> WindowCycleController::BuildWindowList( 168 std::vector<aura::Window*> WindowCycleController::BuildWindowList(
158 const std::list<aura::Window*>* mru_windows) { 169 const std::list<aura::Window*>* mru_windows,
170 bool reverse_order) {
James Cook 2013/03/22 16:45:36 I would either change the sense of this boolean to
159 WindowCycleList::WindowList windows; 171 WindowCycleList::WindowList windows;
160 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 172 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
161 173
162 aura::RootWindow* active_root = Shell::GetActiveRootWindow(); 174 aura::RootWindow* active_root = Shell::GetActiveRootWindow();
163 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); 175 for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
164 iter != root_windows.end(); ++iter) { 176 iter != root_windows.end(); ++iter) {
165 if (*iter == active_root) 177 if (*iter == active_root)
166 continue; 178 continue;
167 for (size_t i = 0; i < arraysize(kContainerIds); ++i) 179 for (size_t i = 0; i < arraysize(kContainerIds); ++i)
168 AddCycleWindows(*iter, kContainerIds[i], &windows); 180 AddCycleWindows(*iter, kContainerIds[i], &windows);
(...skipping 22 matching lines...) Expand all
191 WindowCycleList::WindowList::iterator window = 203 WindowCycleList::WindowList::iterator window =
192 std::find(windows.begin(), windows.end(), *ix); 204 std::find(windows.begin(), windows.end(), *ix);
193 if (window != windows.end()) { 205 if (window != windows.end()) {
194 windows.erase(window); 206 windows.erase(window);
195 windows.push_back(*ix); 207 windows.push_back(*ix);
196 } 208 }
197 } 209 }
198 } 210 }
199 211
200 // Window cycling expects the topmost window at the front of the list. 212 // Window cycling expects the topmost window at the front of the list.
201 std::reverse(windows.begin(), windows.end()); 213 if (!reverse_order)
214 std::reverse(windows.begin(), windows.end());
202 215
203 return windows; 216 return windows;
204 } 217 }
205 218
206 void WindowCycleController::OnRootWindowAdded(aura::RootWindow* root_window) { 219 void WindowCycleController::OnRootWindowAdded(aura::RootWindow* root_window) {
207 for (size_t i = 0; i < arraysize(kContainerIds); ++i) { 220 for (size_t i = 0; i < arraysize(kContainerIds); ++i) {
208 aura::Window* container = 221 aura::Window* container =
209 Shell::GetContainer(root_window, kContainerIds[i]); 222 Shell::GetContainer(root_window, kContainerIds[i]);
210 container->AddObserver(this); 223 container->AddObserver(this);
211 } 224 }
212 225
213 aura::Window* default_container = 226 aura::Window* default_container =
214 Shell::GetContainer(root_window, 227 Shell::GetContainer(root_window,
215 internal::kShellWindowId_DefaultContainer); 228 internal::kShellWindowId_DefaultContainer);
216 for (size_t i = 0; i < default_container->children().size(); ++i) { 229 for (size_t i = 0; i < default_container->children().size(); ++i) {
217 aura::Window* workspace_window = default_container->children()[i]; 230 aura::Window* workspace_window = default_container->children()[i];
218 DCHECK_EQ(internal::kShellWindowId_WorkspaceContainer, 231 DCHECK_EQ(internal::kShellWindowId_WorkspaceContainer,
219 workspace_window->id()); 232 workspace_window->id());
220 workspace_window->AddObserver(this); 233 workspace_window->AddObserver(this);
221 } 234 }
222 } 235 }
223 236
224 ////////////////////////////////////////////////////////////////////////////// 237 //////////////////////////////////////////////////////////////////////////////
225 // WindowCycleController, private: 238 // WindowCycleController, private:
226 239
227 void WindowCycleController::StartCycling() { 240 void WindowCycleController::StartCycling() {
228 windows_.reset(new WindowCycleList(BuildWindowList(&mru_windows_))); 241 windows_.reset(new WindowCycleList(BuildWindowList(&mru_windows_, false)));
229 } 242 }
230 243
231 void WindowCycleController::Step(Direction direction) { 244 void WindowCycleController::Step(Direction direction) {
232 DCHECK(windows_.get()); 245 DCHECK(windows_.get());
233 windows_->Step(direction == FORWARD ? WindowCycleList::FORWARD : 246 windows_->Step(direction == FORWARD ? WindowCycleList::FORWARD :
234 WindowCycleList::BACKWARD); 247 WindowCycleList::BACKWARD);
235 } 248 }
236 249
237 void WindowCycleController::StopCycling() { 250 void WindowCycleController::StopCycling() {
238 windows_.reset(); 251 windows_.reset();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 mru_windows_.remove(window); 296 mru_windows_.remove(window);
284 if (window->id() == internal::kShellWindowId_WorkspaceContainer) 297 if (window->id() == internal::kShellWindowId_WorkspaceContainer)
285 window->RemoveObserver(this); 298 window->RemoveObserver(this);
286 } 299 }
287 300
288 void WindowCycleController::OnWindowDestroying(aura::Window* window) { 301 void WindowCycleController::OnWindowDestroying(aura::Window* window) {
289 window->RemoveObserver(this); 302 window->RemoveObserver(this);
290 } 303 }
291 304
292 } // namespace ash 305 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_cycle_controller.h ('k') | chrome/browser/chromeos/extensions/wallpaper_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698