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

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

Issue 9719037: Aura: Add non-browser windows into the list of "Alt + Tab" cycle list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix 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
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Returns true if children of |window| can be activated. 48 // Returns true if children of |window| can be activated.
49 // These are the only containers in which windows can receive focus. 49 // These are the only containers in which windows can receive focus.
50 bool SupportsChildActivation(aura::Window* window) { 50 bool SupportsChildActivation(aura::Window* window) {
51 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) { 51 for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) {
52 if (window->id() == kWindowContainerIds[i]) 52 if (window->id() == kWindowContainerIds[i])
53 return true; 53 return true;
54 } 54 }
55 return false; 55 return false;
56 } 56 }
57 57
58 bool HasModalTransientChild(aura::Window* window) {
59 aura::Window::Windows::const_iterator it;
60 for (it = window->transient_children().begin();
61 it != window->transient_children().end();
62 ++it) {
63 if ((*it)->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_WINDOW)
64 return true;
65 }
66 return false;
67 }
68
58 // Returns true if |window| can be activated or deactivated. 69 // Returns true if |window| can be activated or deactivated.
59 // A window manager typically defines some notion of "top level window" that 70 // A window manager typically defines some notion of "top level window" that
60 // supports activation/deactivation. 71 // supports activation/deactivation.
61 bool CanActivateWindow(aura::Window* window, const aura::Event* event) { 72 bool CanActivateWindow(aura::Window* window, const aura::Event* event) {
62 return window && 73 return window &&
63 window->IsVisible() && 74 window->IsVisible() &&
64 (!aura::client::GetActivationDelegate(window) || 75 (!aura::client::GetActivationDelegate(window) ||
65 aura::client::GetActivationDelegate(window)->ShouldActivate(event)) && 76 !event ||
sky 2012/03/27 14:59:58 Why are you adding the '!event' clause? It is lega
yoshiki 2012/03/28 15:08:41 Done. Un-changed.
66 SupportsChildActivation(window->parent()); 77 aura::client::GetActivationDelegate(window)->ShouldActivate(event)) &&
78 SupportsChildActivation(window->parent());
sky 2012/03/27 14:59:58 fix indentation.
yoshiki 2012/03/28 15:08:41 Done.
67 } 79 }
68 80
69 // When a modal window is activated, we bring its entire transient parent chain 81 // When a modal window is activated, we bring its entire transient parent chain
70 // to the front. This function must be called before the modal transient is 82 // to the front. This function must be called before the modal transient is
71 // stacked at the top to ensure correct stacking order. 83 // stacked at the top to ensure correct stacking order.
72 void StackTransientParentsBelowModalWindow(aura::Window* window) { 84 void StackTransientParentsBelowModalWindow(aura::Window* window) {
73 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) 85 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW)
74 return; 86 return;
75 87
76 aura::Window* transient_parent = window->transient_parent(); 88 aura::Window* transient_parent = window->transient_parent();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // If |child| isn't activatable, but has transient parent, trace 121 // If |child| isn't activatable, but has transient parent, trace
110 // that path instead. 122 // that path instead.
111 if (child->transient_parent()) 123 if (child->transient_parent())
112 return GetActivatableWindow(child->transient_parent(), event); 124 return GetActivatableWindow(child->transient_parent(), event);
113 parent = parent->parent(); 125 parent = parent->parent();
114 child = child->parent(); 126 child = child->parent();
115 } 127 }
116 return NULL; 128 return NULL;
117 } 129 }
118 130
131 bool ActivationController::CanActivateWindowItself(aura::Window* window) {
132 return CanActivateWindow(window, NULL) && !HasModalTransientChild(window);
133 }
134
119 //////////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////////
120 // ActivationController, aura::client::ActivationClient implementation: 136 // ActivationController, aura::client::ActivationClient implementation:
121 137
122 void ActivationController::ActivateWindow(aura::Window* window) { 138 void ActivationController::ActivateWindow(aura::Window* window) {
123 ActivateWindowWithEvent(window, NULL); 139 ActivateWindowWithEvent(window, NULL);
124 } 140 }
125 141
126 void ActivationController::DeactivateWindow(aura::Window* window) { 142 void ActivationController::DeactivateWindow(aura::Window* window) {
127 if (window) 143 if (window)
128 ActivateNextWindow(window); 144 ActivateNextWindow(window);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 i != container->children().rend(); 289 i != container->children().rend();
274 ++i) { 290 ++i) {
275 if (*i != ignore && CanActivateWindow(*i, NULL)) 291 if (*i != ignore && CanActivateWindow(*i, NULL))
276 return *i; 292 return *i;
277 } 293 }
278 return NULL; 294 return NULL;
279 } 295 }
280 296
281 } // namespace internal 297 } // namespace internal
282 } // namespace ash 298 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698