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

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

Issue 9568045: Activate windows in topmost containers when a window is hidden. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/activation_controller.h ('k') | no next file » | 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/activation_controller.h" 5 #include "ash/wm/activation_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_modality_controller.h" 9 #include "ash/wm/window_modality_controller.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "ui/aura/client/activation_delegate.h" 12 #include "ui/aura/client/activation_delegate.h"
13 #include "ui/aura/client/aura_constants.h" 13 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/env.h" 14 #include "ui/aura/env.h"
15 #include "ui/aura/root_window.h" 15 #include "ui/aura/root_window.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_delegate.h" 17 #include "ui/aura/window_delegate.h"
18 #include "ui/base/ui_base_types.h" 18 #include "ui/base/ui_base_types.h"
19 19
20 namespace ash { 20 namespace ash {
21 namespace internal { 21 namespace internal {
22 namespace { 22 namespace {
23 23
24 // These are the list of container ids of containers which may contain windows
25 // that need to be activated in the order that they should be activated.
26 const int kWindowContainersCount = 5;
sky 2012/03/02 00:20:25 Can't you use arraysize?
flackr 2012/03/02 18:09:28 Cool, thanks! Done.
27 const int kWindowContainers[] = {
28 kShellWindowId_LockSystemModalContainer,
29 kShellWindowId_LockScreenContainer,
30 kShellWindowId_SystemModalContainer,
31 kShellWindowId_AlwaysOnTopContainer,
flackr 2012/03/01 23:51:55 Not sure if this is right. This might be annoying
sky 2012/03/02 00:20:25 Maybe we should start in the container you're in.
flackr 2012/03/02 18:09:28 I like that idea, starting from the container you'
32 kShellWindowId_DefaultContainer,
33 };
34
24 aura::Window* GetContainer(int id) { 35 aura::Window* GetContainer(int id) {
25 return Shell::GetInstance()->GetContainer(id); 36 return Shell::GetInstance()->GetContainer(id);
26 } 37 }
27 38
28 // Returns true if children of |window| can be activated. 39 // Returns true if children of |window| can be activated.
29 // These are the only containers in which windows can receive focus. 40 // These are the only containers in which windows can receive focus.
30 bool SupportsChildActivation(aura::Window* window) { 41 bool SupportsChildActivation(aura::Window* window) {
31 return window->id() == kShellWindowId_DefaultContainer || 42 return window->id() == kShellWindowId_DefaultContainer ||
32 window->id() == kShellWindowId_AlwaysOnTopContainer || 43 window->id() == kShellWindowId_AlwaysOnTopContainer ||
33 window->id() == kShellWindowId_PanelContainer || 44 window->id() == kShellWindowId_PanelContainer ||
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 //////////////////////////////////////////////////////////////////////////////// 212 ////////////////////////////////////////////////////////////////////////////////
202 // ActivationController, private: 213 // ActivationController, private:
203 214
204 void ActivationController::ActivateNextWindow(aura::Window* window) { 215 void ActivationController::ActivateNextWindow(aura::Window* window) {
205 if (wm::IsActiveWindow(window)) 216 if (wm::IsActiveWindow(window))
206 ActivateWindow(GetTopmostWindowToActivate(window)); 217 ActivateWindow(GetTopmostWindowToActivate(window));
207 } 218 }
208 219
209 aura::Window* ActivationController::GetTopmostWindowToActivate( 220 aura::Window* ActivationController::GetTopmostWindowToActivate(
210 aura::Window* ignore) const { 221 aura::Window* ignore) const {
211 const aura::Window* container = 222 if (default_container_for_test_) {
flackr 2012/03/01 23:51:55 Currently this prevents me from testing this prope
sky 2012/03/02 00:20:25 Set it to NULL for your test?
flackr 2012/03/02 18:09:28 Right, I'll do that and use all the standard conta
flackr 2012/03/02 18:12:23 This didn't actually end up being an issue.
212 default_container_for_test_ ? default_container_for_test_ : 223 return GetTopmostWindowToActivateInContainer(default_container_for_test_,
213 GetContainer(kShellWindowId_DefaultContainer); 224 ignore);
214 // When destructing an active window that is in a container destructed after 225 }
215 // the default container during shell shutdown, |container| would be NULL 226
216 // because default container is destructed at this point. 227 aura::Window* window = NULL;
217 if (container) { 228 for (int i = 0; !window && i < kWindowContainersCount; i++) {
218 for (aura::Window::Windows::const_reverse_iterator i = 229 window = GetTopmostWindowToActivateInContainer(
219 container->children().rbegin(); 230 GetContainer(kWindowContainers[i]),
220 i != container->children().rend(); 231 ignore);
221 ++i) { 232 }
222 if (*i != ignore && CanActivateWindow(*i)) 233 return window;
223 return *i; 234 }
224 } 235
236 aura::Window* ActivationController::GetTopmostWindowToActivateInContainer(
237 aura::Window* container,
238 aura::Window* ignore) const {
239 for (aura::Window::Windows::const_reverse_iterator i =
240 container->children().rbegin();
241 i != container->children().rend();
242 ++i) {
243 if (*i != ignore && CanActivateWindow(*i))
244 return *i;
225 } 245 }
226 return NULL; 246 return NULL;
227 } 247 }
228 248
229 } // namespace internal 249 } // namespace internal
230 } // namespace ash 250 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/activation_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698