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

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

Issue 10700057: Add always on top windows to the alt+tab list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a test to verify functionality with multiple desktops Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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
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;
137 aura::Window* default_container = Shell::GetContainer( 138 aura::Window* default_container = Shell::GetContainer(
138 *iter, internal::kShellWindowId_DefaultContainer); 139 *iter, internal::kShellWindowId_DefaultContainer);
139 WindowCycleList::WindowList children = default_container->children(); 140 WindowCycleList::WindowList children = default_container->children();
140 windows.insert(windows.end(), children.begin(), children.end()); 141 windows.insert(windows.end(), children.begin(), children.end());
142
143 aura::Window* always_on_top_container = Shell::GetContainer(
sky 2012/07/17 17:43:37 Shouldn't always on top be added first?
Zachary Kuznia 2012/07/18 01:36:54 It's added last because the container is reversed
144 *iter, internal::kShellWindowId_AlwaysOnTopContainer);
sky 2012/07/17 17:43:37 Rather than this define an array of the ids of the
Zachary Kuznia 2012/07/18 01:36:54 top_windows is handled differently, because they n
145 children = always_on_top_container->children();
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());
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
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
OLDNEW
« no previous file with comments | « no previous file | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698