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

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

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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') | ash/wm/app_list_controller.h » ('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/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 bool VisibilityMatches(aura::Window* window, ActivateVisibilityType type) { 78 bool VisibilityMatches(aura::Window* window, ActivateVisibilityType type) {
79 bool visible = (type == CURRENT_VISIBILITY) ? window->IsVisible() : 79 bool visible = (type == CURRENT_VISIBILITY) ? window->IsVisible() :
80 window->TargetVisibility(); 80 window->TargetVisibility();
81 return visible || wm::IsWindowMinimized(window); 81 return visible || wm::IsWindowMinimized(window);
82 } 82 }
83 83
84 // Returns true if |window| can be activated or deactivated. 84 // Returns true if |window| can be activated or deactivated.
85 // A window manager typically defines some notion of "top level window" that 85 // A window manager typically defines some notion of "top level window" that
86 // supports activation/deactivation. 86 // supports activation/deactivation.
87 bool CanActivateWindowWithEvent(aura::Window* window, 87 bool CanActivateWindowWithEvent(aura::Window* window,
88 const aura::Event* event, 88 const ui::Event* event,
89 ActivateVisibilityType visibility_type) { 89 ActivateVisibilityType visibility_type) {
90 return window && 90 return window &&
91 VisibilityMatches(window, visibility_type) && 91 VisibilityMatches(window, visibility_type) &&
92 (!aura::client::GetActivationDelegate(window) || 92 (!aura::client::GetActivationDelegate(window) ||
93 aura::client::GetActivationDelegate(window)->ShouldActivate(event)) && 93 aura::client::GetActivationDelegate(window)->ShouldActivate(event)) &&
94 SupportsChildActivation(window->parent()); 94 SupportsChildActivation(window->parent());
95 } 95 }
96 96
97 // When a modal window is activated, we bring its entire transient parent chain 97 // When a modal window is activated, we bring its entire transient parent chain
98 // to the front. This function must be called before the modal transient is 98 // to the front. This function must be called before the modal transient is
(...skipping 24 matching lines...) Expand all
123 } 123 }
124 124
125 ActivationController::~ActivationController() { 125 ActivationController::~ActivationController() {
126 aura::Env::GetInstance()->RemoveObserver(this); 126 aura::Env::GetInstance()->RemoveObserver(this);
127 focus_manager_->RemoveObserver(this); 127 focus_manager_->RemoveObserver(this);
128 } 128 }
129 129
130 // static 130 // static
131 aura::Window* ActivationController::GetActivatableWindow( 131 aura::Window* ActivationController::GetActivatableWindow(
132 aura::Window* window, 132 aura::Window* window,
133 const aura::Event* event) { 133 const ui::Event* event) {
134 aura::Window* parent = window->parent(); 134 aura::Window* parent = window->parent();
135 aura::Window* child = window; 135 aura::Window* child = window;
136 while (parent) { 136 while (parent) {
137 if (CanActivateWindowWithEvent(child, event, CURRENT_VISIBILITY)) 137 if (CanActivateWindowWithEvent(child, event, CURRENT_VISIBILITY))
138 return child; 138 return child;
139 // If |child| isn't activatable, but has transient parent, trace 139 // If |child| isn't activatable, but has transient parent, trace
140 // that path instead. 140 // that path instead.
141 if (child->transient_parent()) 141 if (child->transient_parent())
142 return GetActivatableWindow(child->transient_parent(), event); 142 return GetActivatableWindow(child->transient_parent(), event);
143 parent = parent->parent(); 143 parent = parent->parent();
(...skipping 27 matching lines...) Expand all
171 void ActivationController::DeactivateWindow(aura::Window* window) { 171 void ActivationController::DeactivateWindow(aura::Window* window) {
172 if (window) 172 if (window)
173 ActivateNextWindow(window); 173 ActivateNextWindow(window);
174 } 174 }
175 175
176 aura::Window* ActivationController::GetActiveWindow() { 176 aura::Window* ActivationController::GetActiveWindow() {
177 return active_window_; 177 return active_window_;
178 } 178 }
179 179
180 bool ActivationController::OnWillFocusWindow(aura::Window* window, 180 bool ActivationController::OnWillFocusWindow(aura::Window* window,
181 const aura::Event* event) { 181 const ui::Event* event) {
182 return CanActivateWindowWithEvent( 182 return CanActivateWindowWithEvent(
183 GetActivatableWindow(window, event), event, CURRENT_VISIBILITY); 183 GetActivatableWindow(window, event), event, CURRENT_VISIBILITY);
184 } 184 }
185 185
186 //////////////////////////////////////////////////////////////////////////////// 186 ////////////////////////////////////////////////////////////////////////////////
187 // ActivationController, aura::WindowObserver implementation: 187 // ActivationController, aura::WindowObserver implementation:
188 188
189 void ActivationController::OnWindowVisibilityChanged(aura::Window* window, 189 void ActivationController::OnWindowVisibilityChanged(aura::Window* window,
190 bool visible) { 190 bool visible) {
191 if (!visible) { 191 if (!visible) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // ActivationController, aura::RootWindowObserver implementation: 223 // ActivationController, aura::RootWindowObserver implementation:
224 224
225 void ActivationController::OnWindowFocused(aura::Window* window) { 225 void ActivationController::OnWindowFocused(aura::Window* window) {
226 ActivateWindow(GetActivatableWindow(window, NULL)); 226 ActivateWindow(GetActivatableWindow(window, NULL));
227 } 227 }
228 228
229 //////////////////////////////////////////////////////////////////////////////// 229 ////////////////////////////////////////////////////////////////////////////////
230 // ActivationController, private: 230 // ActivationController, private:
231 231
232 void ActivationController::ActivateWindowWithEvent(aura::Window* window, 232 void ActivationController::ActivateWindowWithEvent(aura::Window* window,
233 const aura::Event* event) { 233 const ui::Event* event) {
234 aura::Window* window_modal_transient = wm::GetWindowModalTransient(window); 234 aura::Window* window_modal_transient = wm::GetWindowModalTransient(window);
235 if (window_modal_transient) { 235 if (window_modal_transient) {
236 ActivateWindow(window_modal_transient); 236 ActivateWindow(window_modal_transient);
237 return; 237 return;
238 } 238 }
239 239
240 // Prevent recursion when called from focus. 240 // Prevent recursion when called from focus.
241 if (updating_activation_) 241 if (updating_activation_)
242 return; 242 return;
243 243
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 if (*i != ignore && 343 if (*i != ignore &&
344 CanActivateWindowWithEvent(*i, NULL, CURRENT_VISIBILITY) && 344 CanActivateWindowWithEvent(*i, NULL, CURRENT_VISIBILITY) &&
345 !wm::IsWindowMinimized(*i)) 345 !wm::IsWindowMinimized(*i))
346 return *i; 346 return *i;
347 } 347 }
348 return NULL; 348 return NULL;
349 } 349 }
350 350
351 } // namespace internal 351 } // namespace internal
352 } // namespace ash 352 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/activation_controller.h ('k') | ash/wm/app_list_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698