| 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 13 matching lines...) Expand all Loading... |
| 24 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) | 24 if (window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_WINDOW) |
| 25 return; | 25 return; |
| 26 | 26 |
| 27 aura::Window* transient_parent = window->transient_parent(); | 27 aura::Window* transient_parent = window->transient_parent(); |
| 28 while (transient_parent) { | 28 while (transient_parent) { |
| 29 transient_parent->parent()->StackChildAtTop(transient_parent); | 29 transient_parent->parent()->StackChildAtTop(transient_parent); |
| 30 transient_parent = transient_parent->transient_parent(); | 30 transient_parent = transient_parent->transient_parent(); |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Stack's |window|'s layer above |relative_to|'s layer. |
| 35 void StackWindowLayerAbove(aura::Window* window, aura::Window* relative_to) { |
| 36 // Stack |window| above the last transient child of |relative_to| that shares |
| 37 // the same parent. |
| 38 const aura::Window::Windows& window_transients( |
| 39 relative_to->transient_children()); |
| 40 for (aura::Window::Windows::const_iterator i = window_transients.begin(); |
| 41 i != window_transients.end(); ++i) { |
| 42 aura::Window* transient = *i; |
| 43 if (transient->parent() == relative_to->parent()) |
| 44 relative_to = transient; |
| 45 } |
| 46 if (window != relative_to) { |
| 47 window->layer()->parent()->StackAbove(window->layer(), |
| 48 relative_to->layer()); |
| 49 } |
| 50 } |
| 51 |
| 34 } // namespace | 52 } // namespace |
| 35 | 53 |
| 36 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
| 37 // FocusController, public: | 55 // FocusController, public: |
| 38 | 56 |
| 39 FocusController::FocusController(FocusRules* rules) | 57 FocusController::FocusController(FocusRules* rules) |
| 40 : active_window_(NULL), | 58 : active_window_(NULL), |
| 41 focused_window_(NULL), | 59 focused_window_(NULL), |
| 42 updating_focus_(false), | 60 updating_focus_(false), |
| 43 updating_activation_(false), | 61 updating_activation_(false), |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 //////////////////////////////////////////////////////////////////////////////// | 211 //////////////////////////////////////////////////////////////////////////////// |
| 194 // FocusController, aura::WindowObserver implementation: | 212 // FocusController, aura::WindowObserver implementation: |
| 195 | 213 |
| 196 void FocusController::OnWindowVisibilityChanged(aura::Window* window, | 214 void FocusController::OnWindowVisibilityChanged(aura::Window* window, |
| 197 bool visible) { | 215 bool visible) { |
| 198 if (!visible) { | 216 if (!visible) { |
| 199 WindowLostFocusFromDispositionChange(window, window->parent()); | 217 WindowLostFocusFromDispositionChange(window, window->parent()); |
| 200 // Despite the focus change, we need to keep the window being hidden | 218 // Despite the focus change, we need to keep the window being hidden |
| 201 // stacked above the new window so it stays open on top as it animates away. | 219 // stacked above the new window so it stays open on top as it animates away. |
| 202 aura::Window* next_window = GetActiveWindow(); | 220 aura::Window* next_window = GetActiveWindow(); |
| 203 if (next_window && next_window->parent() == window->parent()) { | 221 if (next_window && next_window->parent() == window->parent()) |
| 204 window->layer()->parent()->StackAbove(window->layer(), | 222 StackWindowLayerAbove(window, next_window); |
| 205 next_window->layer()); | |
| 206 } | |
| 207 } | 223 } |
| 208 } | 224 } |
| 209 | 225 |
| 210 void FocusController::OnWindowDestroying(aura::Window* window) { | 226 void FocusController::OnWindowDestroying(aura::Window* window) { |
| 211 WindowLostFocusFromDispositionChange(window, window->parent()); | 227 WindowLostFocusFromDispositionChange(window, window->parent()); |
| 212 } | 228 } |
| 213 | 229 |
| 214 void FocusController::OnWindowHierarchyChanging( | 230 void FocusController::OnWindowHierarchyChanging( |
| 215 const HierarchyChangeParams& params) { | 231 const HierarchyChangeParams& params) { |
| 216 if (params.receiver == active_window_ && | 232 if (params.receiver == active_window_ && |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 SetFocusedWindow(rules_->GetFocusableWindow(next)); | 333 SetFocusedWindow(rules_->GetFocusableWindow(next)); |
| 318 } | 334 } |
| 319 } | 335 } |
| 320 | 336 |
| 321 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { | 337 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { |
| 322 FocusWindow(window); | 338 FocusWindow(window); |
| 323 } | 339 } |
| 324 | 340 |
| 325 } // namespace corewm | 341 } // namespace corewm |
| 326 } // namespace views | 342 } // namespace views |
| OLD | NEW |