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