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

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

Issue 149493008: Use active window if on current workspace for fullscreen mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
OLDNEW
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"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Move minimized windows to the beginning (LRU end) of the list. 125 // Move minimized windows to the beginning (LRU end) of the list.
126 std::stable_sort(windows.begin(), windows.end(), CompareWindowState); 126 std::stable_sort(windows.begin(), windows.end(), CompareWindowState);
127 127
128 // Window cycling expects the topmost window at the front of the list. 128 // Window cycling expects the topmost window at the front of the list.
129 if (!top_most_at_end) 129 if (!top_most_at_end)
130 std::reverse(windows.begin(), windows.end()); 130 std::reverse(windows.begin(), windows.end());
131 131
132 return windows; 132 return windows;
133 } 133 }
134 134
135 // A comparator for locating a window in a given root window.
136 struct WindowInRoot
137 : public std::unary_function<const aura::Window*, bool> {
138 explicit WindowInRoot(const aura::Window* root)
139 : root_window(root) {
140 }
141
142 bool operator()(const aura::Window* item) const {
143 return item->GetRootWindow() == root_window;
oshima 2014/02/10 19:21:06 I'd prefer just looping for simple pointer compari
flackr 2014/02/10 21:45:28 Done.
144 }
145
146 const aura::Window* root_window;
147 };
148
135 } // namespace 149 } // namespace
136 150
137 const int kSwitchableWindowContainerIds[] = { 151 const int kSwitchableWindowContainerIds[] = {
138 internal::kShellWindowId_DefaultContainer, 152 internal::kShellWindowId_DefaultContainer,
139 internal::kShellWindowId_AlwaysOnTopContainer, 153 internal::kShellWindowId_AlwaysOnTopContainer,
140 internal::kShellWindowId_PanelContainer 154 internal::kShellWindowId_PanelContainer
141 }; 155 };
142 156
143 const size_t kSwitchableWindowContainerIdsLength = 157 const size_t kSwitchableWindowContainerIdsLength =
144 arraysize(kSwitchableWindowContainerIds); 158 arraysize(kSwitchableWindowContainerIds);
(...skipping 29 matching lines...) Expand all
174 188
175 void MruWindowTracker::SetIgnoreActivations(bool ignore) { 189 void MruWindowTracker::SetIgnoreActivations(bool ignore) {
176 ignore_window_activations_ = ignore; 190 ignore_window_activations_ = ignore;
177 191
178 // If no longer ignoring window activations, move currently active window 192 // If no longer ignoring window activations, move currently active window
179 // to front. 193 // to front.
180 if (!ignore) 194 if (!ignore)
181 SetActiveWindow(wm::GetActiveWindow()); 195 SetActiveWindow(wm::GetActiveWindow());
182 } 196 }
183 197
198 const aura::Window* MruWindowTracker::GetMruWindowInRoot(
199 const aura::Window* root_window) {
200 std::list<aura::Window*>::const_iterator mru_in_root =
201 std::find_if(mru_windows_.begin(), mru_windows_.end(),
202 WindowInRoot(root_window));
203 if (mru_in_root == mru_windows_.end())
204 return NULL;
205 return *mru_in_root;
206 }
207
184 ////////////////////////////////////////////////////////////////////////////// 208 //////////////////////////////////////////////////////////////////////////////
185 // MruWindowTracker, private: 209 // MruWindowTracker, private:
186 210
187 void MruWindowTracker::SetActiveWindow(aura::Window* active_window) { 211 void MruWindowTracker::SetActiveWindow(aura::Window* active_window) {
188 if (!active_window) 212 if (!active_window)
189 return; 213 return;
190 214
191 std::list<aura::Window*>::iterator iter = 215 std::list<aura::Window*>::iterator iter =
192 std::find(mru_windows_.begin(), mru_windows_.end(), active_window); 216 std::find(mru_windows_.begin(), mru_windows_.end(), active_window);
193 // Observe all newly tracked windows. 217 // Observe all newly tracked windows.
(...skipping 16 matching lines...) Expand all
210 234
211 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) { 235 void MruWindowTracker::OnWindowDestroyed(aura::Window* window) {
212 // It's possible for OnWindowActivated() to be called after 236 // It's possible for OnWindowActivated() to be called after
213 // OnWindowDestroying(). This means we need to override OnWindowDestroyed() 237 // OnWindowDestroying(). This means we need to override OnWindowDestroyed()
214 // else we may end up with a deleted window in |mru_windows_|. 238 // else we may end up with a deleted window in |mru_windows_|.
215 mru_windows_.remove(window); 239 mru_windows_.remove(window);
216 window->RemoveObserver(this); 240 window->RemoveObserver(this);
217 } 241 }
218 242
219 } // namespace ash 243 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698