OLD | NEW |
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 "ui/views/corewm/focus_controller.h" | 5 #include "ui/views/corewm/focus_controller.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "ui/aura/client/activation_change_observer.h" | 8 #include "ui/aura/client/activation_change_observer.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/capture_client.h" | 10 #include "ui/aura/client/capture_client.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 observer_manager_.Remove(active_window_); | 278 observer_manager_.Remove(active_window_); |
279 } | 279 } |
280 active_window_ = window; | 280 active_window_ = window; |
281 if (active_window_ && !observer_manager_.IsObserving(active_window_)) | 281 if (active_window_ && !observer_manager_.IsObserving(active_window_)) |
282 observer_manager_.Add(active_window_); | 282 observer_manager_.Add(active_window_); |
283 if (active_window_) { | 283 if (active_window_) { |
284 StackTransientParentsBelowModalWindow(active_window_); | 284 StackTransientParentsBelowModalWindow(active_window_); |
285 active_window_->parent()->StackChildAtTop(active_window_); | 285 active_window_->parent()->StackChildAtTop(active_window_); |
286 } | 286 } |
287 | 287 |
288 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, | |
289 activation_observers_, | |
290 OnWindowActivated(active_window_, lost_activation)); | |
291 aura::client::ActivationChangeObserver* observer = | 288 aura::client::ActivationChangeObserver* observer = |
292 aura::client::GetActivationChangeObserver(lost_activation); | 289 aura::client::GetActivationChangeObserver(lost_activation); |
293 if (observer) | 290 if (observer) |
294 observer->OnWindowActivated(active_window_, lost_activation); | 291 observer->OnWindowActivated(active_window_, lost_activation); |
295 observer = aura::client::GetActivationChangeObserver(active_window_); | 292 observer = aura::client::GetActivationChangeObserver(active_window_); |
296 if (observer) | 293 if (observer) |
297 observer->OnWindowActivated(active_window_, lost_activation); | 294 observer->OnWindowActivated(active_window_, lost_activation); |
| 295 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, |
| 296 activation_observers_, |
| 297 OnWindowActivated(active_window_, lost_activation)); |
298 } | 298 } |
299 | 299 |
300 void FocusController::WindowLostFocusFromDispositionChange( | 300 void FocusController::WindowLostFocusFromDispositionChange( |
301 aura::Window* window, | 301 aura::Window* window, |
302 aura::Window* next) { | 302 aura::Window* next) { |
303 // A window's modality state will interfere with focus restoration during its | 303 // A window's modality state will interfere with focus restoration during its |
304 // destruction. | 304 // destruction. |
305 window->ClearProperty(aura::client::kModalKey); | 305 window->ClearProperty(aura::client::kModalKey); |
306 // TODO(beng): See if this function can be replaced by a call to | 306 // TODO(beng): See if this function can be replaced by a call to |
307 // FocusWindow(). | 307 // FocusWindow(). |
308 // Activation adjustments are handled first in the event of a disposition | 308 // Activation adjustments are handled first in the event of a disposition |
309 // changed. If an activation change is necessary, focus is reset as part of | 309 // changed. If an activation change is necessary, focus is reset as part of |
310 // that process so there's no point in updating focus independently. | 310 // that process so there's no point in updating focus independently. |
311 if (window == active_window_) { | 311 if (window == active_window_) { |
312 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window); | 312 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window); |
313 SetActiveWindow(next_activatable); | 313 SetActiveWindow(next_activatable); |
314 SetFocusedWindow(next_activatable); | 314 SetFocusedWindow(next_activatable); |
315 } else if (window->Contains(focused_window_)) { | 315 } else if (window->Contains(focused_window_)) { |
316 // Active window isn't changing, but focused window might be. | 316 // Active window isn't changing, but focused window might be. |
317 SetFocusedWindow(rules_->GetFocusableWindow(next)); | 317 SetFocusedWindow(rules_->GetFocusableWindow(next)); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 321 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
322 FocusWindow(window); | 322 FocusWindow(window); |
323 } | 323 } |
324 | 324 |
325 } // namespace corewm | 325 } // namespace corewm |
326 } // namespace views | 326 } // namespace views |
OLD | NEW |