| 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/wm/core/focus_controller.h" | 5 #include "ui/wm/core/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" |
| 11 #include "ui/aura/client/focus_change_observer.h" | 11 #include "ui/aura/client/focus_change_observer.h" |
| 12 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/window_tracker.h" | 13 #include "ui/aura/window_tracker.h" |
| 14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 15 #include "ui/wm/core/focus_rules.h" | 15 #include "ui/wm/core/focus_rules.h" |
| 16 #include "ui/wm/core/window_util.h" | 16 #include "ui/wm/core/window_util.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace wm { |
| 19 namespace corewm { | |
| 20 namespace { | 19 namespace { |
| 21 | 20 |
| 22 // When a modal window is activated, we bring its entire transient parent chain | 21 // When a modal window is activated, we bring its entire transient parent chain |
| 23 // to the front. This function must be called before the modal transient is | 22 // to the front. This function must be called before the modal transient is |
| 24 // stacked at the top to ensure correct stacking order. | 23 // stacked at the top to ensure correct stacking order. |
| 25 void StackTransientParentsBelowModalWindow(aura::Window* window) { | 24 void StackTransientParentsBelowModalWindow(aura::Window* window) { |
| 26 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) | 25 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) |
| 27 return; | 26 return; |
| 28 | 27 |
| 29 aura::Window* transient_parent = views::corewm::GetTransientParent(window); | 28 aura::Window* transient_parent = wm::GetTransientParent(window); |
| 30 while (transient_parent) { | 29 while (transient_parent) { |
| 31 transient_parent->parent()->StackChildAtTop(transient_parent); | 30 transient_parent->parent()->StackChildAtTop(transient_parent); |
| 32 transient_parent = views::corewm::GetTransientParent(transient_parent); | 31 transient_parent = wm::GetTransientParent(transient_parent); |
| 33 } | 32 } |
| 34 } | 33 } |
| 35 | 34 |
| 36 // Stack's |window|'s layer above |relative_to|'s layer. | 35 // Stack's |window|'s layer above |relative_to|'s layer. |
| 37 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) { | 36 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) { |
| 38 // Stack |window| above the last transient child of |relative_to| that shares | 37 // Stack |window| above the last transient child of |relative_to| that shares |
| 39 // the same parent. | 38 // the same parent. |
| 40 const aura::Window::Windows& window_transients( | 39 const aura::Window::Windows& window_transients( |
| 41 GetTransientChildren(relative_to)); | 40 GetTransientChildren(relative_to)); |
| 42 for (aura::Window::Windows::const_iterator i = window_transients.begin(); | 41 for (aura::Window::Windows::const_iterator i = window_transients.begin(); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 367 } |
| 369 | 368 |
| 370 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 369 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
| 371 // Only focus |window| if it or any of its parents can be focused. Otherwise | 370 // Only focus |window| if it or any of its parents can be focused. Otherwise |
| 372 // FocusWindow() will focus the topmost window, which may not be the | 371 // FocusWindow() will focus the topmost window, which may not be the |
| 373 // currently focused one. | 372 // currently focused one. |
| 374 if (rules_->CanFocusWindow(GetToplevelWindow(window))) | 373 if (rules_->CanFocusWindow(GetToplevelWindow(window))) |
| 375 FocusWindow(window); | 374 FocusWindow(window); |
| 376 } | 375 } |
| 377 | 376 |
| 378 } // namespace corewm | 377 } // namespace wm |
| 379 } // namespace views | |
| OLD | NEW |